unicorn, rails, and symlinked deployment

Michael Guterl mguterl at gmail.com
Wed Nov 18 10:34:38 EST 2009

On Tue, Nov 17, 2009 at 5:20 PM, Eric Wong <normalperson at yhbt.net> wrote:
> Michael Guterl <mguterl at gmail.com> wrote:
>> First let me say thanks for Unicorn, it has helped us fill a gap that
>> Passenger could not fill.
>> Like many using Rails, we use capistrano for deployment.  At the end
>> of each deployment we use the standard capistrano deploy:cleanup task
>> to remove old releases.  Everything is fine until we cleanup the
>> release directory from which unicorn_rails was originally launched.
>> When this happens we get an error in our unicorn error log.
>> reloading config_file=/home/deploy/public_html/rm/releases/20091116213921/config/unicorn.rb
>> error reloading
>> config_file=/home/deploy/public_html/rm/releases/20091116213921/config/unicorn.rb:
>> Errno::ENOENT No such file or directory -
>> /home/deploy/public_html/rm/releases/20091116213921/config/unicorn.rb
>> I'm sure I'm not the only who has experienced this.  Does anyone have
>> any recommendations for handling this situation?
> Hi Michael,
> Unicorn was definitely implemented with Cap in mind.  Which version of
> Unicorn are you running?  0.94.0 got better symlink detection for
> non-GNU/Linux systems, so if you start in
> /home/deploy/public_html/rm/current, then it should detect it and use
> /home/deploy/public_html/rm/current/config/unicorn.rb.
I am using unicorn v0.94.0 on Ubuntu 8.04.

> If you don't start in your "current" symlink dir, 0.94.0 also got
> support for "working_directory" in your config file.
I set this option in my config, however, it did not help.

After some experimentation I realized the problem is in the script I
use for managing unicorn via /etc/init.d --

Essentially start does this:

cd ~/public_html/rm/current
unicorn_rails -D -E production -c config/unicorn.rb

I determined the -c config/unicorn.rb was the problem.  If I change it to:

unicorn_rails -D -E production -c ~/public_html/rm/current/config/unicorn.rb

everything works fine.

My updated init script is located at http://gist.github.com/237958 and
it seems to work fine.

Best regards,
Michael Guterl

More information about the mongrel-unicorn mailing list