Created
November 24, 2012 08:23
-
-
Save kain-jy/4138867 to your computer and use it in GitHub Desktop.
[rails] unicorn configure
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
# save config/unicorn.rb | |
worker_processes 2 | |
working_directory "/home/{project_name}/app" | |
listen '/home/{project_name}/tmp/unicorn.sock' | |
stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) | |
stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) | |
preload_app true | |
before_fork do |server, worker| | |
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! | |
old_pid = "#{ server.config[:pid] }.oldbin" | |
unless old_pid == server.pid | |
begin | |
Process.kill :QUIT, File.read(old_pid).to_i | |
rescue Errno::ENOENT, Errno::ESRCH | |
end | |
end | |
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