DataChomp

Chomping At The Bits

Using Unicorn With Sinatra or Padrino on Heroku

My apps on Heroku have been cruising along ok using Thin as my rack server, but on my VPS boxes, Unicorn. I was hoping to keep a more consistent experience for myself and as it turns out, getting my Heroku apps to run on Unicorn is pretty simple and runs really fast.

1st: I added a Unicorn config file: touch config/unicorn.rb and added the following:
worker_processes 3
timeout 30
preload_app true

2nd: I added Unicorn to my GemFile:
#rack server
gem ‘unicorn’
You will want to “bundle install” after that step so that it gets picked up and added to your Gemfile.lock

3rd: I added a Procfile to the root of my app: touch Procfile and added the following:
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

Commit it into Git, then git push heroku branchname and you are enjoying the sweet sweet threading love of Unicorn.