Last active
December 21, 2015 17:49
-
-
Save masahirosuzuka/6343397 to your computer and use it in GitHub Desktop.
Rails3.2 + Nginx + Unicorn + Capisterno Unicorn設定ファイル
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
# -*- coding: utf-8 -*- | |
worker_processes 2 | |
working_directory "/var/www/raiqoo/current" | |
listen "/tmp/unicorn.sock" | |
pid "/tmp/unicorn.pid" | |
timeout 60 | |
preload_app true # ダウンタイムをなくす | |
stdout_path "/var/www/raiqoo/current/log/unicorn.stdout.log" | |
stderr_path "/var/www/raiqoo/current/log/unicorn.stderr.log" | |
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! | |
old_pid = "#{server.config[:pid]}.oldbin" | |
if old_pid != server.pid | |
begin | |
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU | |
Process.kill(sig, File.read(old_pid).to_i) | |
rescue Errno::ENOENT, Errno::ESRCH | |
end | |
end | |
sleep 1 | |
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