about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-03-01 10:36:54 +0000
committerEric Wong <normalperson@yhbt.net>2010-03-01 10:38:40 +0000
commitcdec2a634c85b92aa95d4c1f0ce2a056e332dfca (patch)
treeec3306a49fb7a982ec5294de6ed96db9e5eef26d
parent98d605423b3a563de7b2d0b5f37695a4cf5bed7a (diff)
downloadzbatery-cdec2a634c85b92aa95d4c1f0ce2a056e332dfca.tar.gz
support Unicorn 0.96.0+ ready_pipe daemonization
ready_pipe allows the controlling process to detect
errors more reliably.
-rwxr-xr-xbin/zbatery2
-rw-r--r--lib/zbatery.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/bin/zbatery b/bin/zbatery
index daa5c79..fe7b011 100755
--- a/bin/zbatery
+++ b/bin/zbatery
@@ -124,5 +124,5 @@ if $DEBUG
   })
 end
 
-Unicorn::Launcher.daemonize! if daemonize
+Unicorn::Launcher.daemonize!(options) if daemonize
 Zbatery.run(app, options)
diff --git a/lib/zbatery.rb b/lib/zbatery.rb
index fb05318..9704839 100644
--- a/lib/zbatery.rb
+++ b/lib/zbatery.rb
@@ -96,6 +96,13 @@ module Zbatery
       rescue => e # hopefully ignores errors on Win32...
         logger.error "failed to setup signal handler: #{e.message}"
       end
+
+      if ready_pipe
+        ready_pipe.syswrite($$.to_s)
+        ready_pipe.close rescue nil
+        self.ready_pipe = nil
+      end
+
       worker = Worker.new(0, DeadIO.new)
       before_fork.call(self, worker)
       worker_loop(worker) # runs forever