Deploy Sinatra app on Heroku

demas picture demas · Mar 27, 2012 · Viewed 11.8k times · Source

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?

Answer

Patrick Oscity picture Patrick Oscity · Mar 27, 2012

Here's how to create a minimal sinatra app that deploys to heroku:

app.rb:

require 'sinatra'

get '/' do
  "hello world"
end

Gemfile:

source 'https://rubygems.org'

gem 'heroku'
gem 'sinatra'
gem 'thin'

config.ru:

require './app'
run Sinatra::Application

Type these commands in your command line to deploy (without the $ signs):

$ bundle install
$ git init
$ git add -f app.rb Gemfile Gemfile.lock config.ru
$ git commit -am "initial commit"
$ heroku create <my-app-name>
$ git push heroku master

Then test your app:

$ curl <my-app-name>.heroku.com

and you should see:

hello world