diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-04-02 01:49:38 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-04-02 02:36:33 -0700 |
commit | 5b1606270052ca374cdabc920166f64d38376f15 (patch) | |
tree | 079bf585619446b0adf9ec33c572a558f6dba207 /lib | |
parent | eb34caa3f4b8cedddb14b9e4e0415e2258802134 (diff) | |
download | unicorn-5b1606270052ca374cdabc920166f64d38376f15.tar.gz |
Multiple Unicorn applications one machine can get confusing quickly. Regardless, make it easy to distinguish between workers and the master process.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/unicorn.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index c6a4e36..02e0363 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -167,7 +167,7 @@ module Unicorn QUEUE_SIGS.each { |sig| trap_deferred(sig) } trap(:CHLD) { |sig_nr| awaken_master } - $0 = "unicorn master" + proc_name 'master' logger.info "master process ready" # test_exec.rb relies on this message begin loop do @@ -286,7 +286,7 @@ module Unicorn logger.error "reaped #{status.inspect} exec()-ed" @reexec_pid = 0 self.pid = @pid.chomp('.oldbin') if @pid - $0 = "unicorn master" + proc_name 'master' else worker = @workers.delete(pid) worker.tempfile.close rescue nil @@ -348,7 +348,7 @@ module Unicorn @before_exec.call(self) if @before_exec exec(*cmd) end - $0 = "unicorn master (old)" + proc_name 'master (old)' end # forcibly terminate all workers that haven't checked in in @timeout @@ -428,7 +428,7 @@ module Unicorn QUEUE_SIGS.each { |sig| trap(sig, 'IGNORE') } trap(:CHLD, 'DEFAULT') - $0 = "unicorn worker[#{worker.nr}]" + proc_name "worker[#{worker.nr}]" @rd_sig.close if @rd_sig @wr_sig.close if @wr_sig @workers.values.each { |other| other.tempfile.close rescue nil } @@ -588,5 +588,10 @@ module Unicorn @app = @app.call if @app.respond_to?(:arity) && @app.arity == 0 end + def proc_name(tag) + $0 = ([ @start_ctx[:zero].sub(%r{\A.*?([^/]+)\z}, '\1'), tag ] + + @start_ctx[:argv]).join(' ') + end + end end |