about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-11-07 02:05:31 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-07 02:05:31 +0000
commit59c9c3c2c1904e74739d23f2574f0e7cdbf1a474 (patch)
tree887ef6f52090b982b2607fb7965ca5d2d9fe6252
parent950815b313a4e616c6fe39f46b2e894b51d7d62f (diff)
downloadyahns-59c9c3c2c1904e74739d23f2574f0e7cdbf1a474.tar.gz
We must know we're daemonized after a SIGUSR2 upgrade, even if we
don't use the pipe to signal to the controlling terminal we've
started up.
-rw-r--r--lib/yahns/daemon.rb6
-rw-r--r--lib/yahns/server.rb2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/yahns/daemon.rb b/lib/yahns/daemon.rb
index f6cdf47..fd93fd7 100644
--- a/lib/yahns/daemon.rb
+++ b/lib/yahns/daemon.rb
@@ -19,7 +19,11 @@ module Yahns::Daemon # :nodoc:
 
     # We only start a new process group if we're not being reexecuted
     # and inheriting file descriptors from our parent
-    unless ENV['YAHNS_FD']
+    if ENV['YAHNS_FD']
+      # if we're inheriting, need to ensure this remains true so
+      # SIGWINCH works when worker processes are in play
+      yahns_server.daemon_pipe = true
+    else
       # grandparent - reads pipe, exits when master is ready
       #  \_ parent  - exits immediately ASAP
       #      \_ yahns master - writes to pipe when ready
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb
index 3c0c330..9790783 100644
--- a/lib/yahns/server.rb
+++ b/lib/yahns/server.rb
@@ -201,7 +201,7 @@ class Yahns::Server # :nodoc:
   end
 
   def daemon_ready
-    @daemon_pipe or return
+    @daemon_pipe.respond_to?(:syswrite) or return
     @daemon_pipe.syswrite("#$$")
     @daemon_pipe.close
     @daemon_pipe = true # for SIGWINCH