Created
January 25, 2013 09:36
-
-
Save Hengjie/4633113 to your computer and use it in GitHub Desktop.
Minimize Unicorn worker_processes in 'development' env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production' | |
# Save on RAM while in development | |
if environment == 'development' | |
worker_processes 1 | |
else | |
worker_processes 4 | |
end | |
timeout 30 | |
preload_app true | |
before_fork do |server, worker| | |
# Close all open connections | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.connection.disconnect! | |
end | |
@resque_pid ||= spawn("bundle exec rake resque:work QUEUES=fast") | |
end | |
after_fork do |server, worker| | |
# Reopen all connections | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.establish_connection | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment