What is required to deploy a Sinatra(Ruby) app to a live server?
-
Please describe the files necessary to deploy the app to a live server such as Heroku, Digital Ocean, etc. and what is happening during the deployment process. I just rushed though the tutorials on Heroku previously, but I would like a deeper understanding. For example, what exactly is happening in the config.ru Please discus additional steps are required from having an app functioning locally, to an app being live on a server.
-
Answer:
With Heroku, you need to instruct what you want it to do. The config.ru is configuring http://rack.github.io/, a webserver interface for Ruby apps including Sinatra. This is what you need to run your application in development or production. Heroku automatically configures the development/production switch. How to tell if your code is development/production Sinatra::Base.development? # => true (if localhost) Sinatra::Base.production? # => false (unless if production) Source: https://devcenter.heroku.com/articles/rack on Heroku.
Bilawal Hameed at Quora Visit the source
Other answers
First you need a web server. This is usually Apache or nginx (pronounced "engine-x"). The web server listens on port 80 (and/or port 443 for https) then routes the request to the application server. There are several application servers designed to run Ruby applications. The most popular are Passenger, Unicorn, and Puma. Passenger is the easiest to install and use. Puma was the fastest. Now with the latest version of Passenger (5.0), it's now both the easiest and fastest. I would recommend using Passenger. Heroku handles both of those things for you. All of the app servers I mentioned implement the Rack standard. The app server loads the http://config.ru ("rack up" file) which specifies a class that responds to a "call" method, receives a hash of request options, and responds with an array of status code, http headers, and the response body. Sinatra handles this part for you, making it as simple as defining the routes you want to respond to. The app server will keep the app running in memory until you stop the server or restart it. So during the deployment process, the code is updated and the app server is told to restart.
Andrew Havens
Related Q & A:
- What are the chances of a 19 year old having a heart attack?Best solution by Yahoo! Answers
- What is required to become a physical therapist?Best solution by Yahoo! Answers
- What's the difference between a US version PSP and a Japan version PSP?Best solution by Yahoo! Answers
- What countries do I need a tourist visa for as a Canadian?Best solution by en.wikipedia.org
- What is required to be a dentist?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.