File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,15 @@ worker process. Use the PIDFILE option for easy access to the PID:
265265
266266 $ PIDFILE=./resque.pid QUEUE=file_serve rake environment resque:work
267267
268+ ### Running in the background
269+
270+ (Only supported with ruby >= 1.9). There are scenarios where it's helpful for
271+ the resque worker to run itself in the background (usually in combination with
272+ PIDFILE). Use the BACKGROUND option so that rake will return as soon as the
273+ worker is started.
274+
275+ $ PIDFILE=./resque.pid BACKGROUND=yes QUEUE=file_serve \
276+ rake environment resque:work
268277
269278### Priorities and Queue Lists
270279
Original file line number Diff line number Diff line change 1818 abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
1919 end
2020
21+ if ENV [ 'BACKGROUND' ]
22+ unless Process . respond_to? ( 'daemon' )
23+ abort "env var BACKGROUND is set, which requires ruby >= 1.9"
24+ end
25+ Process . daemon ( true )
26+ end
27+
2128 if ENV [ 'PIDFILE' ]
2229 File . open ( ENV [ 'PIDFILE' ] , 'w' ) { |f | f << worker . pid }
2330 end
Original file line number Diff line number Diff line change @@ -480,7 +480,7 @@ def hostname
480480
481481 # Returns Integer PID of running worker
482482 def pid
483- @pid ||= to_s . split ( ":" ) [ 1 ] . to_i
483+ Process . pid
484484 end
485485
486486 # Returns an Array of string pids of all the other workers on this
You can’t perform that action at this time.
0 commit comments