-
Notifications
You must be signed in to change notification settings - Fork 1
/
unicorn.rb
28 lines (25 loc) · 859 Bytes
/
unicorn.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
# -*- encoding: utf-8; -*-
listen 4000
worker_processes 8
pid "tmp/pids/unicorn.pid"
before_fork do |server, worker|
# Single server rolling reaper.
# 1. Start new master, flag old as old
# 2. Bring up 1 new worker and request old master gently kill one worker
# 3. Repeat until all old workers are dead
# 4. Reap old master
old_pid = "#{server.config[:pid]}.oldbin"
if File.exist?(old_pid) && 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
# someone else did our job for us
end
sleep 1 # Time between each new worker thread start (single thread warmup period)
end
end
if RACKUP[:daemonized]
stdout_path "log/mogilefs_s3_device.log"
stderr_path "log/mogilefs_s3_device.log"
end