unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: RAILS_ROOT and USR2 restarts
Date: Mon, 26 Oct 2009 09:01:58 -0700	[thread overview]
Message-ID: <20091026160158.GA16220@dcvr.yhbt.net> (raw)
In-Reply-To: <d7a220010910260804n4f403vb1cdc526db6d3aea@mail.gmail.com>

Ian Leitch <port001@gmail.com> wrote:
> Hi,
> 
> I've just started using Unicorn in production behind Nginx with a
> Rails app, for the most part its been a smooth transition apart from
> this one issue.
> When I do an in place restart (USR2), the restart process works but
> the workers load my old Rails release, not the new one. I'm guessing
> that because the master process is currently in the old release
> directory, when I signal USR2 it's just reloading inside the current
> directory. I'm deploying with Capistrano, so app/current is a symlink
> to a specific release. I've tried changing to the new release
> directory in before_work but that made no difference. Is there a
> callback that fires before the master preloads the app?

Hi Ian,

Unicorn chdirs to the directory returned by `/bin/sh -c pwd` when it was
originally started.  The output of `pwd` *should* be symlink-aware, but
then Solaris /bin/sh is weird.  Can you confirm that it's broken?

You can put the following in your config (outside of the hooks):

  app_root = "/var/www/apps/systino_production/current"
  Dir.chdir(Unicorn::HttpServer::START_CTX[:cwd] = app_root)

I've been pondering adding a "working_directory" directive to
Configurator, too.  However the START_CTX hash is considered a stable
interface and I recently documented it in
http://unicorn.bogomips.org/Unicorn.html

START_CTX even allows you to switch between different installation paths
for Unicorn[1] and alter command line options that were originally
passed.  Lots of rope there :>

[1] for different Ruby installs/versions,
    or even swap in Rainbows! or vice versa

-- 
Eric Wong

  reply	other threads:[~2009-10-26 16:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-26 15:04 RAILS_ROOT and USR2 restarts Ian Leitch
2009-10-26 16:01 ` Eric Wong [this message]
2009-10-26 16:13   ` Ian Leitch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091026160158.GA16220@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).