forked from docmeta/rubydoc.info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunicorn.conf.rb
29 lines (27 loc) · 1.01 KB
/
unicorn.conf.rb
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
28
29
worker_processes 1
working_directory Dir.pwd
listen 8080, :tcp_nopush => true
pid "#{Dir.pwd}/tmp/pids/unicorn.pid"
stderr_path "#{Dir.pwd}/log/unicorn.log"
stdout_path "#{Dir.pwd}/log/unicorn.log"
preload_app true
before_fork do |server, worker|
##
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
# immediately start loading up a new version of itself (loaded with a new
# version of our app). When this new Unicorn is completely loaded
# it will begin spawning workers. The first worker spawned will check to
# see if an .oldbin pidfile exists. If so, this means we've just booted up
# a new Unicorn and need to tell the old one that it can now die. To do so
# we send it a QUIT.
#
# Using this method we get 0 downtime deploys.
old_pid = "#{Dir.pwd}/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
# someone else did our job for us
end
end
end