From c7ac1f09cd6302aec3394e9057c6e30f5bc28288 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 10 Feb 2009 16:02:34 -0800 Subject: Set default process title This can be overridden in {after,before}_fork hooks of course; but makes things look a little nicer. --- lib/unicorn.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3-24-ge0c7