summaryrefslogtreecommitdiff
path: root/doc/unicorn.rb
blob: 7f51822c3b6dba7f5af3adc3033ec603e292f921 (plain)
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
30
31
32
33
34
35
36
# This usually is deployed to /usr/local/etc/unicorn.rb
# and then executed from the rc.d/cccms script
#
#
# unicorn -c /usr/local/etc/unicorn.rb -E production -D

stderr_path "/var/log/unicorn.stderr.log"

rails_env = ENV['RAILS_ENV'] || 'production'

worker_processes (rails_env == 'production' ? 32 : 4)

preload_app true

timeout 30

listen "0.0.0.0:9090", tcp_nopush: false

pid "/usr/local/www/cccms/tmp/pids/unicorn.pid"

before_fork do |server, worker|
  old_pid = Rails.root.to_s + '/tmp/pids/unicorn.pid.oldbin'
  if File.exist?(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

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection
end

user 'www', 'www'