Pidfiles and cwd?

Eric Wong normalperson at
Sat Sep 5 13:15:14 EDT 2009

Eric Wong <normalperson at> wrote:
> > B) Is there a reason `unicorn_rails` must start in the app root and
> > doesn't allow it as a config option?
> Since the config file is just Ruby, you can just Dir.chdir inside it.
> And since the chdir is done when the config file is evaluated, the
> chdir can be done across restarts/reloads (you can point it to a
> symlinked directory) to pick up new code/releases.
> If you do that, I would initially start Unicorn in "/" or some other
> directory that won't get deleted so you'll be safe for upgrades.
> If you managed to forget that, you can set the following in your
> Unicorn config:
>   Unicorn::HttpServer::START_CTX[:cwd] = "/"

Maybe having a 'working_directory "/path/to/app/root"' that does:

  Dir.chdir(Unicorn::HttpServer::START_CTX[:cwd] = arg)

Internally would make things easier?

I see nginx has a "working_directory" config option as well:

Eric Wong

More information about the mongrel-unicorn mailing list