Skip to content

Instantly share code, notes, and snippets.

@kyv
Created August 28, 2012 17:49
Show Gist options
  • Save kyv/3501351 to your computer and use it in GitHub Desktop.
Save kyv/3501351 to your computer and use it in GitHub Desktop.
unicorn.rb
worker_processes 4
user "http", "http"
working_directory "/etc/unicorn" # available in 0.94.0+
listen "/tmp/.sock", :backlog => 64
timeout 30
pid "/var/run/unicorn/unicorn.pid"
stderr_path "/var/log/unicorn/error.log"
stdout_path "/var/log/unicorn/out.log"
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment