lib/resque/worker.rb in resque-1.4.0 vs lib/resque/worker.rb in resque-1.5.0

- old
+ new

@@ -113,27 +113,23 @@ if not @paused and job = reserve log "got: #{job.inspect}" if @child = fork rand # Reseeding - procline = "resque: Forked #{@child} at #{Time.now.to_i}" - $0 = procline - log! procline + procline "Forked #{@child} at #{Time.now.to_i}" Process.wait else - procline = "resque: Processing #{job.queue} since #{Time.now.to_i}" - $0 = procline - log! procline + procline "Processing #{job.queue} since #{Time.now.to_i}" process(job, &block) exit! unless @cant_fork end @child = nil else break if interval.to_i == 0 log! "Sleeping for #{interval.to_i}" - $0 = @paused ? "resque: Paused" : "resque: Waiting for #{@queues.join(',')}" + procline @paused ? "Paused" : "Waiting for #{@queues.join(',')}" sleep interval.to_i end end ensure @@ -416,9 +412,17 @@ # machine. Useful when pruning dead workers on startup. def worker_pids `ps -A -o pid,command | grep [r]esque`.split("\n").map do |line| line.split(' ')[0] end + end + + # Given a string, sets the procline ($0) and logs. + # Procline is always in the format of: + # resque-VERSION: STRING + def procline(string) + $0 = "resque-#{Resque::Version}: #{string}" + log! $0 end # Log a message to STDOUT if we are verbose or very_verbose. def log(message) if verbose