Skip to content

Commit

Permalink
Version now included in procline, e.g. resque-1.5.0: Message
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Feb 13, 2010
1 parent 79b0f09 commit 5cdf011
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 1.4.1 (2010-??-??)
## 1.5.0 (2010-??-??)

* Version now included in procline, e.g. `resque-1.5: Message`
* Web bugfix: Ignore idle works in the "working" page

## 1.4.0 (2010-02-11)
Expand Down
15 changes: 8 additions & 7 deletions lib/resque/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,10 @@ def work(interval = 5, &block)

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
Expand All @@ -131,7 +127,7 @@ def work(interval = 5, &block)
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
Expand Down Expand Up @@ -420,6 +416,11 @@ def worker_pids
end
end

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
Expand Down
3 changes: 2 additions & 1 deletion test/worker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@

test "sets $0 while working" do
@worker.work(0) do
assert_equal "resque: Processing jobs since #{Time.now.to_i}", $0
ver = Resque::Version
assert_equal "resque-#{ver}: Processing jobs since #{Time.now.to_i}", $0
end
end

Expand Down

0 comments on commit 5cdf011

Please sign in to comment.