From 5b1606270052ca374cdabc920166f64d38376f15 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 2 Apr 2009 01:49:38 -0700 Subject: More descriptive process titles Multiple Unicorn applications one machine can get confusing quickly. Regardless, make it easy to distinguish between workers and the master process. --- lib/unicorn.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3-24-ge0c7