Skip to content

Instantly share code, notes, and snippets.

@kitop
Created February 18, 2013 22:30
Show Gist options
  • Save kitop/4981364 to your computer and use it in GitHub Desktop.
Save kitop/4981364 to your computer and use it in GitHub Desktop.
Unicorn config example
# config/unicorn.rb
worker_processes 4
timeout 30
preload_app true
before_fork do |server, worker|
# Replace with your ORM of choice
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
# Replace with your Background Worker of choice or any other configuration
if defined?(Resque)
Resque.redis.quit
end
end
after_fork do |server, worker|
# Replace with your ORM of choice
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
end
# Replace with your Background Worker of choice or any other configuration
if defined?(Resque)
Resque.redis = ENV['REDISTOGO_URL']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment