Search code examples
rubyherokusinatra

Deploy Sinatra app on Heroku


I have simple Sinatra app.

web.rb:

require 'sinatra'

get '/' do 
    "Hello" 
end

Gemfile:*

source :rubygems

gem 'sinatra', '1.1.0'
gem 'thin', '1.2.7'

config.ru:

require './web'
run Sinatra::Application

But when I deploy my app on Heroku I'll get the error on logs:

2012-03-27T19:17:48+00:00 heroku[router]: Error H14 (No web processes running) -> GET furious-waterfall-6586.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=

How can I fix it?


Solution

  • 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.