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: Changing Ruby version
Date: Thu, 14 Feb 2013 20:20:07 +0000	[thread overview]
Message-ID: <20130214202007.GA23895@dcvr.yhbt.net> (raw)
In-Reply-To: <CANrRGgo+Gq9pkCprcmbH5aOtbtN796nL-WuKXSA=WJT_3ebTug@mail.gmail.com>

Jérémy Lecour <jeremy.lecour@gmail.com> wrote:
> Hi,
> 
> I'm using Unicorn with rbenv to have different Ruby versions between projects.
> 
> This morning, I wanted to change the Ruby version used by an app.
> I've updated the content of .ruby-version, then sent a USR2 signal to
> the master process to restart Unicorn (as I always do).
> 
> I've noticed that it was still using the "old" Ruby binary.

I'm not familiar with rbenv, but you need to use the same "unicorn"
executable script for both installations (changing the shebang (#!)
line will do.

Otherwise, you can tweak Unicorn::HttpServer::START_CTX
(ref: http://unicorn.bogomips.org/Unicorn/HttpServer.html )

> If I started a new irb console, the Ruby was correct.

This is probably because the shell you started irb from has the new
environment variables needed to find your new Ruby.  unicorn was
started from a different parent shell/process which had different
environment variables.

You may also need to modify ENV in a before_exec hook if there are
other environment variables your app depends on which a different
Ruby installation would change.

> Then I thought that maybe the way forking works allows to change the
> version of Unicorn itself and everything "below", but not the Ruby
> binary.
> 
> Am I right ?
> Is there a way to do a rolling restart and change the Ruby binary at
> the same time?

What you're doing is switching between Ruby installations (to different
paths).  unicorn still supports this, but it's a little more involved
and involves modifying START_CTX (and possibly ENV).

The "upgrade" case is easiest when a new version of Ruby is installed
over the old one (this is the common case for OS package managers
(e.g.  RPM/dpkg/ports)).
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

  reply	other threads:[~2013-02-14 20:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 14:10 Changing Ruby version Jérémy Lecour
2013-02-14 20:20 ` Eric Wong [this message]
2013-02-14 21:35   ` Jérémy Lecour

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=20130214202007.GA23895@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).