Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bvandenbos/resque-scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandenbos committed Sep 27, 2011
2 parents 41296b0 + b97fa2e commit 7a3ba75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ supersedes `VERBOSE`.

NOTE: You DO NOT want to run >1 instance of the scheduler. Doing so will
result in the same job being queued more than once. You only need one
instnace of the scheduler running per resque instance (regardless of number
instance of the scheduler running per resque instance (regardless of number
of machines).

If the scheduler process goes down for whatever reason, the delayed items
Expand Down Expand Up @@ -265,6 +265,16 @@ Now make sure you're passing that file to resque-web like so:

That should make the scheduler tabs show up in `resque-web`.

### Running in the background

(Only supported with ruby >= 1.9). There are scenarios where it's helpful for
the resque worker to run itself in the background (usually in combination with
PIDFILE). Use the BACKGROUND option so that rake will return as soon as the
worker is started.

$ PIDFILE=./resque-scheduler.pid BACKGROUND=yes \
rake resque:scheduler

### Plagiarism alert

This was intended to be an extension to resque and so resulted in a lot of the
Expand Down
7 changes: 7 additions & 0 deletions lib/resque_scheduler/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
require 'resque'
require 'resque_scheduler'

if ENV['BACKGROUND']
unless Process.respond_to?('daemon')
abort "env var BACKGROUND is set, which requires ruby >= 1.9"
end
Process.daemon(true)
end

File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid.to_s } if ENV['PIDFILE']

Resque::Scheduler.dynamic = true if ENV['DYNAMIC_SCHEDULE']
Expand Down

0 comments on commit 7a3ba75

Please sign in to comment.