unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Tatsuya Ono <ononoma@gmail.com>
To: mongrel-unicorn <mongrel-unicorn@rubyforge.org>
Subject: Unicorn in the jail
Date: Wed, 3 Aug 2011 17:41:03 +0100
Message-ID: <CAHBuKRj09FdxAgzsefJWotexw-7JYZGJMtgUp_dhjPz9VbKD6Q@mail.gmail.com> (raw)

I ran into a problem when sending USR2 signal to master process which
is listening a TCP port. It shows the following error in log.

err: adding listener failed addr= (in use)

I found similar error reported on this mailing list and yes, the host
I got the error was in the FreeBSD jail.

I dug into the problem and found some interesting thing. I want to
share it and the solution here.

* Why does it happen in the Jail?
When you bind address to the socket on a Jail host, Jail
doesn't bind Instead of it, it binds to the IP address of the
host such as,, etc.
Then the problem happens in Unicorn::HttpServer#inherit_listeners!
when it gets signal like USR2.

Here you get (for example) as inherited address from
ENV['UNICORN_FD'] but So Unicorn tries to bind to
(again) at line 728. Then it fails because it is actually in use.

* How to solve the issue?
Thankfully unicorn.conf is ruby script so that I could write a logic
for Jail hosts without specifying IP address of those hosts (which we
want to avoid since we deploy it multiple servers). I share the
configuration file.

Then Unicorn flies in the jail happily.

Tatsuya Ono
Unicorn mailing list - mongrel-unicorn@rubyforge.org
Do not quote signatures (like this one) or top post when replying

             reply	other threads:[~2011-08-03 16:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 16:41 Tatsuya Ono [this message]
2011-08-03 18:03 ` Eric Wong
2011-08-03 21:57   ` Tatsuya Ono

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:

  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=CAHBuKRj09FdxAgzsefJWotexw-7JYZGJMtgUp_dhjPz9VbKD6Q@mail.gmail.com \
    --to=ononoma@gmail.com \
    --cc=mongrel-unicorn@rubyforge.org \
    --subject='Re: Unicorn in the jail' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhbt.net/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 unicorn-public unicorn-public/ https://yhbt.net/unicorn-public \
		unicorn-public@yhbt.net unicorn-public@bogomips.org mongrel-unicorn@rubyforge.org mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
	public-inbox-index unicorn-public

Example config snippet for mirrors.
Newsgroups are available over NNTP:
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git