about summary refs log tree commit homepage
path: root/lib/unicorn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-02-10 16:02:34 -0800
committerEric Wong <normalperson@yhbt.net>2009-02-10 16:02:34 -0800
commitc7ac1f09cd6302aec3394e9057c6e30f5bc28288 (patch)
tree4130e3da979b562a2358d0ab270cbf2b93fbf86a /lib/unicorn.rb
parent4c70ae68f978137955ed780273d1d3b7fa644f4f (diff)
downloadunicorn-c7ac1f09cd6302aec3394e9057c6e30f5bc28288.tar.gz
This can be overridden in {after,before}_fork hooks
of course; but makes things look a little nicer.
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r--lib/unicorn.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index f877686..210d278 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -159,7 +159,7 @@ module Unicorn
       @rd_sig.nonblock = @wr_sig.nonblock = true
 
       %w(QUIT INT TERM USR1 USR2 HUP).each { |sig| trap_deferred(sig) }
-
+      $0 = "unicorn master"
       begin
         loop do
           reap_all_workers
@@ -373,8 +373,9 @@ module Unicorn
     # to free some resources and drops all sig handlers.
     # traps for USR1, USR2, and HUP may be set in the @after_fork Proc
     # by the user.
-    def init_worker_process
+    def init_worker_process(worker)
       %w(TERM INT QUIT USR1 USR2 HUP).each { |sig| trap(sig, 'IGNORE') }
+      $0 = "unicorn worker[#{worker.nr}]"
       @rd_sig.close if @rd_sig
       @wr_sig.close if @wr_sig
       @workers.values.each { |other| other.tempfile.close rescue nil }
@@ -384,14 +385,14 @@ module Unicorn
       @listeners.each { |sock| set_cloexec(sock) }
       ENV.delete('UNICORN_DAEMONIZE')
       ENV.delete('UNICORN_FD')
+      @after_fork.call(self, worker.nr) if @after_fork
     end
 
     # runs inside each forked worker, this sits around and waits
     # for connections and doesn't die until the parent dies (or is
     # given a INT, QUIT, or TERM signal)
     def worker_loop(worker)
-      init_worker_process
-      @after_fork.call(self, worker.nr) if @after_fork
+      init_worker_process(worker)
       nr = 0
       tempfile = worker.tempfile
       alive = true