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=0.0.0.0:3010 (in use) I found similar error reported on this mailing list and yes, the host I got the error was in the FreeBSD jail. http://rubyforge.org/pipermail/mongrel-unicorn/2009-December/000205.html http://rubyforge.org/pipermail/mongrel-unicorn/2009-December/000212.html 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 0.0.0.0 address to the socket on a Jail host, Jail doesn''t bind 0.0.0.0. Instead of it, it binds to the IP address of the host such as 10.100.1.50, 192.168.1.50, etc. Then the problem happens in Unicorn::HttpServer#inherit_listeners! when it gets signal like USR2. https://github.com/defunkt/unicorn/blob/406b8b0e2ed6e5be34d8ec3cd4b16048233c2856/lib/unicorn/http_server.rb#L703-731 Here you get 10.100.1.50 (for example) as inherited address from ENV[''UNICORN_FD''] but 0.0.0.0. So Unicorn tries to bind to 0.0.0.0 (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. https://gist.github.com/1122965 Then Unicorn flies in the jail happily. Tatsuya Ono
Thanks! I''ve pushed out the following patch and updated the site:>From ec8a8f32d257290aac377f1c7b1c496e1df75f73 Mon Sep 17 00:00:00 2001From: Eric Wong <normalperson at yhbt.net> Date: Wed, 3 Aug 2011 11:00:28 -0700 Subject: [PATCH] KNOWN_ISSUES: add link to FreeBSD jail workaround notes Thanks to Tatsuya Ono on the unicorn mailing list. --- KNOWN_ISSUES | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES index 2bd4151..f323c68 100644 --- a/KNOWN_ISSUES +++ b/KNOWN_ISSUES @@ -3,6 +3,9 @@ Occasionally odd {issues}[link:ISSUES.html] arise without a transparent or acceptable solution. Those issues are documented here. +* Issues with FreeBSD jails can be worked around as documented by Tatsuya Ono: + http://mid.gmane.org/CAHBuKRj09FdxAgzsefJWotexw-7JYZGJMtgUp_dhjPz9VbKD6Q at mail.gmail.com + * PRNGs (pseudo-random number generators) loaded before forking (e.g. "preload_app true") may need to have their internal state reset in the after_fork hook. Starting with \Unicorn 3.6.1, we -- Eric Wong
Thank you, Eric! Tatsuya On 3 August 2011 19:03, Eric Wong <normalperson at yhbt.net> wrote:> > Thanks! ?I''ve pushed out the following patch and updated the site: > > >From ec8a8f32d257290aac377f1c7b1c496e1df75f73 Mon Sep 17 00:00:00 2001 > From: Eric Wong <normalperson at yhbt.net> > Date: Wed, 3 Aug 2011 11:00:28 -0700 > Subject: [PATCH] KNOWN_ISSUES: add link to FreeBSD jail workaround notes > > Thanks to Tatsuya Ono on the unicorn mailing list. > --- > ?KNOWN_ISSUES | ? ?3 +++ > ?1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES > index 2bd4151..f323c68 100644 > --- a/KNOWN_ISSUES > +++ b/KNOWN_ISSUES > @@ -3,6 +3,9 @@ > ?Occasionally odd {issues}[link:ISSUES.html] arise without a transparent or > ?acceptable solution. ?Those issues are documented here. > > +* Issues with FreeBSD jails can be worked around as documented by Tatsuya Ono: > + ?http://mid.gmane.org/CAHBuKRj09FdxAgzsefJWotexw-7JYZGJMtgUp_dhjPz9VbKD6Q at mail.gmail.com > + > ?* PRNGs (pseudo-random number generators) loaded before forking > ? (e.g. "preload_app true") may need to have their internal state > ? reset in the after_fork hook. ?Starting with \Unicorn 3.6.1, we > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying