about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-09 16:14:34 -0700
committerEric Wong <normalperson@yhbt.net>2010-06-10 02:53:45 +0000
commit4c5faa3c001d695330f49fbed162d97e31f60357 (patch)
tree906ed363993f06754479d62d0fa82b553f47b9d1 /lib
parentbfb10e16337c99fccfc86b37cff9b78857b0fa1c (diff)
downloadunicorn-4c5faa3c001d695330f49fbed162d97e31f60357.tar.gz
Rainbows! and Zbatery have long been upgraded to
pass options to us.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn/launcher.rb64
1 files changed, 31 insertions, 33 deletions
diff --git a/lib/unicorn/launcher.rb b/lib/unicorn/launcher.rb
index e71f93b..5ab04c7 100644
--- a/lib/unicorn/launcher.rb
+++ b/lib/unicorn/launcher.rb
@@ -19,47 +19,45 @@ class Unicorn::Launcher
   #     the directory it was started in when being re-executed
   #     to pickup code changes if the original deployment directory
   #     is a symlink or otherwise got replaced.
-  def self.daemonize!(options = nil)
+  def self.daemonize!(options)
     $stdin.reopen("/dev/null")
 
     # We only start a new process group if we're not being reexecuted
     # and inheriting file descriptors from our parent
-    unless ENV['UNICORN_FD']
-      if options
-        # grandparent - reads pipe, exits when master is ready
-        #  \_ parent  - exits immediately ASAP
-        #      \_ unicorn master - writes to pipe when ready
-
-        rd, wr = IO.pipe
-        grandparent = $$
-        if fork
-          wr.close # grandparent does not write
-        else
-          rd.close # unicorn master does not read
-          Process.setsid
-          exit if fork # parent dies now
-        end
+    if ENV['UNICORN_FD']
+      exit if fork
+      Process.setsid
+      exit if fork
+    else
+      # grandparent - reads pipe, exits when master is ready
+      #  \_ parent  - exits immediately ASAP
+      #      \_ unicorn master - writes to pipe when ready
+
+      rd, wr = IO.pipe
+      grandparent = $$
+      if fork
+        wr.close # grandparent does not write
+      else
+        rd.close # unicorn master does not read
+        Process.setsid
+        exit if fork # parent dies now
+      end
 
-        if grandparent == $$
-          # this will block until HttpServer#join runs (or it dies)
-          master_pid = (rd.readpartial(16) rescue nil).to_i
-          unless master_pid > 1
-            warn "master failed to start, check stderr log for details"
-            exit!(1)
-          end
-          exit 0
-        else # unicorn master process
-          options[:ready_pipe] = wr
+      if grandparent == $$
+        # this will block until HttpServer#join runs (or it dies)
+        master_pid = (rd.readpartial(16) rescue nil).to_i
+        unless master_pid > 1
+          warn "master failed to start, check stderr log for details"
+          exit!(1)
         end
-      else # backwards compat
-        exit if fork
-        Process.setsid
-        exit if fork
+        exit 0
+      else # unicorn master process
+        options[:ready_pipe] = wr
       end
-      # $stderr/$stderr can/will be redirected separately in the Unicorn config
-      Unicorn::Configurator::DEFAULTS[:stderr_path] = "/dev/null"
-      Unicorn::Configurator::DEFAULTS[:stdout_path] = "/dev/null"
     end
+    # $stderr/$stderr can/will be redirected separately in the Unicorn config
+    Unicorn::Configurator::DEFAULTS[:stderr_path] = "/dev/null"
+    Unicorn::Configurator::DEFAULTS[:stdout_path] = "/dev/null"
   end
 
 end