Skip to content

Instantly share code, notes, and snippets.

@nordringrayhide
Created May 12, 2012 21:29
Show Gist options
  • Save nordringrayhide/2669196 to your computer and use it in GitHub Desktop.
Save nordringrayhide/2669196 to your computer and use it in GitHub Desktop.
Rails foreman gem configs
# Usage: bundle --binstubs && bin/foreman start
gem 'unicorn', '~> 4.3.1'
group :development do
gem 'foreman', '~> 0.46.0'
end
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
worker_processes 3 # amount of unicorn workers to spin up
timeout 15 # restarts workers that hang for 15 seconds
preload_app true
before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
end
after_fork do |server, worker|
require 'my_app'
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment