[PATCH] SIGHUP no longer drops lone, default listener

Eric Wong normalperson at yhbt.net
Thu Sep 17 02:04:37 EDT 2009


The following patch (or something functionally equivalent) along with
some sort of test case will be in the next release of Unicorn (due this
week along with more documentation updates).

Until then, if you're not explicitly specifying a listener anywhere,
specify one, even if it's the default (preferably in the config file) if
you plan on using SIGHUP to reload configs.

Just add the following line to your config file:

	listen 8080

>From beefdb590c4cae9671bd96bf94962634ecbc6161 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson at yhbt.net>
Date: Wed, 16 Sep 2009 22:31:20 -0700
Subject: [PATCH] SIGHUP no longer drops lone, default listener

When SIGHUP reloads the config, we didn't account for the case
where the listen socket was completely unspecified.  Thus the
default listener (TCP port 8080), did not get preserved and
reinjected into the config properly.

Note that relying on the default listen or specifying listeners
on the command-line means it's practically impossible to unbind
listeners with a configuration file reload.  We also need to
preserve the (unspecified) default listener across upgrades that
later result in SIGHUP, too; so we inject the default listener
into the command-line for upgrades.
---
 lib/unicorn.rb |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 4cc5c2d..0e46261 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -110,6 +110,8 @@ module Unicorn
       config_listeners -= listener_names
       if config_listeners.empty? && LISTENERS.empty?
         config_listeners << Unicorn::Const::DEFAULT_LISTEN
+        init_listeners << Unicorn::Const::DEFAULT_LISTEN
+        START_CTX[:argv] << "-l#{Unicorn::Const::DEFAULT_LISTEN}"
       end
       config_listeners.each { |addr| listen(addr) }
       raise ArgumentError, "no listeners" if LISTENERS.empty?
-- 
Eric Wong


More information about the mongrel-unicorn mailing list