Commit f391c7905643844778afa31d0d92f66412c54c18

Authored by Stephen Crosby
2 parents 9436c036 793659e2
Exists in master and in 1 other branch production

Merge pull request #777 from errbit/default_unicorn_config

move unicorn.rb to unicorn.default.rb
Procfile
1   -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
  1 +web: bundle exec unicorn -p $PORT -c ./config/unicorn.default.rb
... ...
config/unicorn.default.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
  2 +
  3 +worker_processes 3 # amount of unicorn workers to spin up
  4 +timeout 30 # restarts workers that hang for 30 seconds
  5 +preload_app true
  6 +
  7 +# Taken from github: https://github.com/blog/517-unicorn
  8 +# Though everyone uses pretty miuch the same code
  9 +before_fork do |server, worker|
  10 + ##
  11 + # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
  12 + # immediately start loading up a new version of itself (loaded with a new
  13 + # version of our app). When this new Unicorn is completely loaded
  14 + # it will begin spawning workers. The first worker spawned will check to
  15 + # see if an .oldbin pidfile exists. If so, this means we've just booted up
  16 + # a new Unicorn and need to tell the old one that it can now die. To do so
  17 + # we send it a QUIT.
  18 + #
  19 + # Using this method we get 0 downtime deploys.
  20 +
  21 + old_pid = "#{server.config[:pid]}.oldbin"
  22 + if File.exists?(old_pid) && server.pid != old_pid
  23 + begin
  24 + Process.kill("QUIT", File.read(old_pid).to_i)
  25 + rescue Errno::ENOENT, Errno::ESRCH
  26 + # someone else did our job for us
  27 + end
  28 + end
  29 +end
... ...
config/unicorn.rb
... ... @@ -1,29 +0,0 @@
1   -# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
2   -
3   -worker_processes 3 # amount of unicorn workers to spin up
4   -timeout 30 # restarts workers that hang for 30 seconds
5   -preload_app true
6   -
7   -# Taken from github: https://github.com/blog/517-unicorn
8   -# Though everyone uses pretty miuch the same code
9   -before_fork do |server, worker|
10   - ##
11   - # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
12   - # immediately start loading up a new version of itself (loaded with a new
13   - # version of our app). When this new Unicorn is completely loaded
14   - # it will begin spawning workers. The first worker spawned will check to
15   - # see if an .oldbin pidfile exists. If so, this means we've just booted up
16   - # a new Unicorn and need to tell the old one that it can now die. To do so
17   - # we send it a QUIT.
18   - #
19   - # Using this method we get 0 downtime deploys.
20   -
21   - old_pid = "#{server.config[:pid]}.oldbin"
22   - if File.exists?(old_pid) && server.pid != old_pid
23   - begin
24   - Process.kill("QUIT", File.read(old_pid).to_i)
25   - rescue Errno::ENOENT, Errno::ESRCH
26   - # someone else did our job for us
27   - end
28   - end
29   -end