diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-22 15:33:06 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-22 15:33:06 +0100 |
commit | 39aa7132ceed3d4beab3a9b828e571bbfc67c07e (patch) | |
tree | 6c88289c9f99be0af8635636fcdf64102090e5ec /config/unicorn.rb | |
parent | 5ad8203ce4f1bfea997960d0b52c626dea24b944 (diff) | |
parent | 6f69c1a85055ec7c2515719d79d2a7a4e60cec50 (diff) |
Merge branch 'develop'5.1-beta1
Diffstat (limited to 'config/unicorn.rb')
-rw-r--r-- | config/unicorn.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 0000000..8157562 --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,34 @@ +APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__))) + +worker_processes 1 +working_directory APP_ROOT + +preload_app true + +timeout 30 + +listen APP_ROOT + "/tmp/sockets/unicorn.sock", :backlog => 64 + +pid APP_ROOT + "/tmp/pids/unicorn.pid" + +stderr_path APP_ROOT + "/log/unicorn.stderr.log" +stdout_path APP_ROOT + "/log/unicorn.stdout.log" + +before_fork do |server, worker| + defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! + + old_pid = Rails.root + '/tmp/pids/unicorn.pid.oldbin' + if File.exists?(old_pid) && server.pid != old_pid + begin + Process.kill("QUIT", File.read(old_pid).to_i) + rescue Errno::ENOENT, Errno::ESRCH + puts "Old master alerady dead" + end + end +end + +after_fork do |server, worker| + defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection + child_pid = server.config[:pid].sub('.pid', ".#{worker.nr}.pid") + system("echo #{Process.pid} > #{child_pid}") +end |