From 793659e277f38181951df3e1cb15a5f53b76e5e2 Mon Sep 17 00:00:00 2001 From: Stephen Crosby Date: Thu, 1 Jan 2015 20:52:34 -0800 Subject: [PATCH] move unicorn.rb to unicorn.default.rb --- Procfile | 2 +- config/unicorn.default.rb | 29 +++++++++++++++++++++++++++++ config/unicorn.rb | 29 ----------------------------- 3 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 config/unicorn.default.rb delete mode 100644 config/unicorn.rb diff --git a/Procfile b/Procfile index 9c82374..b9b4d97 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb +web: bundle exec unicorn -p $PORT -c ./config/unicorn.default.rb diff --git a/config/unicorn.default.rb b/config/unicorn.default.rb new file mode 100644 index 0000000..58b2d13 --- /dev/null +++ b/config/unicorn.default.rb @@ -0,0 +1,29 @@ +# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/ + +worker_processes 3 # amount of unicorn workers to spin up +timeout 30 # restarts workers that hang for 30 seconds +preload_app true + +# Taken from github: https://github.com/blog/517-unicorn +# Though everyone uses pretty miuch the same code +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 = "#{server.config[: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 diff --git a/config/unicorn.rb b/config/unicorn.rb deleted file mode 100644 index 58b2d13..0000000 --- a/config/unicorn.rb +++ /dev/null @@ -1,29 +0,0 @@ -# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/ - -worker_processes 3 # amount of unicorn workers to spin up -timeout 30 # restarts workers that hang for 30 seconds -preload_app true - -# Taken from github: https://github.com/blog/517-unicorn -# Though everyone uses pretty miuch the same code -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 = "#{server.config[: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 -- libgit2 0.21.2