Capistrano and Unicorn
steve at steveklabnik.com
Thu Feb 18 15:41:20 EST 2010
Anyone have any tips for using Capistrano with unicorn?
I'm following what GitHub did (http://github.com/blog/517-unicorn) ,
and for some reason, my old master isn't dying correctly. If I `pkill
-9 unicorn_rails && unicorn_rails` the new code shows up. I'm thinking
the problem may be with how capistrano uses the 'current' directory as
That config's before_fork seems to make sense to me; I might just be
doing something stupid.
Here's my config, for reference:
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
working_directory "/home/git/site/current" # available in 0.94.0+
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/.sock", :backlog => 64
listen 8080, :tcp_nopush => true
# some applications/frameworks log to stderr or stdout, so prevent
# them from going to /dev/null when daemonized here:
# combine REE with "preload_app true" for memory savings
GC.copy_on_write_friendly = true
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
old_pid = RAILS_ROOT + '/tmp/pids/unicorn.pid.oldbin'
if File.exists?(old_pid) && server.pid != old_pid
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
after_fork do |server, worker|
# the following is *required* for Rails + "preload_app true",
I am using ree, so preload_app should be in effect.
Thanks in advance.
More information about the mongrel-unicorn