Deploy Sinatra app on Heroku
You need a Procfile
file alongside your config.ru
to tell Heroku how to run your app. Here is the content of an example Procfile
:
web: bundle exec ruby web.rb -p $PORT
Heroku Ruby docs on Procfiles
EDIT: Here's a sample config.ru
from one of my sinatra/Heroku apps:
$:.unshift File.expand_path("../", __FILE__)
require 'rubygems'
require 'sinatra'
require './web'
run Sinatra::Application
You may need to require sinatra and rubygems for it to work.
How can I deploy this Ruby/Sinatra app to Heroku?
Remove gem 'dbm'
from your Gemfile.
That dbm gem only works with jruby and you don't need it since you are using yaml/dbm.
How can I deploy a Sinatra-based Ruby web app to Heroku?
When deploying from a different branch into Heroku's master branch, you need to specify the branch in the push command: git push heroku heroku:master
.
Do I need a Procfile to push a Sinatra app to Heroku?
Heroku knows how to launch different types of applications by default and it tries to detect your type of app when you deploy. If you have a config.ru
for example, Heroku knows you’re deploying a rack app and then rack uses that file.
A custom Procfile is needed if you want to customize the command that boots up your application, for example to run it with a different webserver or to start an additional worker process.
So: You don’t need a Procfile for default app configurations (like most Sinatra or Rails Apps for example).
More info here: https://devcenter.heroku.com/articles/procfile
Related Topics
Recommended Approach to Monkey Patching a Class in Ruby
How to Get All Class Names in a Namespace in Ruby
Find File Path of a Given Class
Modifying Database Ids from Rails Console
Purpose of & (Ampersand) in Ruby for Procs and Calling Methods
How to I Make Private Class Constants in Ruby
Which Gem Support Import/Export to Xlsx File in Ruby
Ruby: How to Iterate Over an Array of Hashes and Return the Values in a Single String
How to Convert Nokogiri Document Object into JSON
How to Initialize an Array Inside a Hash in Ruby
Check Whether a String Contains One of Multiple Substrings
How to Install Ruby on Rails 3.0 on Ubuntu 10.10
Passing Error Messages Through Flash
Find Most Common String in an Array