public
Created

Minimize Unicorn worker_processes in 'development' env

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.