Skip to content

Instantly share code, notes, and snippets.

@jgv
Created February 6, 2013 23:12
Show Gist options
  • Save jgv/4726764 to your computer and use it in GitHub Desktop.
Save jgv/4726764 to your computer and use it in GitHub Desktop.
Our unicorn config for Heroku.
worker_processes 4
timeout 30
preload_app true
listen 3000 if ENV["RAILS_ENV"] == "development"
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end
sleep 1
end
after_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
Rails.logger.info('Connected to ActiveRecord')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment