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:
265
265
266
266
$ PIDFILE=./resque.pid QUEUE=file_serve rake environment resque:work
267
267
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
268
277
269
278
### Priorities and Queue Lists
270
279
Original file line number Diff line number Diff line change 18
18
abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
19
19
end
20
20
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
+
21
28
if ENV [ 'PIDFILE' ]
22
29
File . open ( ENV [ 'PIDFILE' ] , 'w' ) { |f | f << worker . pid }
23
30
end
Original file line number Diff line number Diff line change @@ -480,7 +480,7 @@ def hostname
480
480
481
481
# Returns Integer PID of running worker
482
482
def pid
483
- @pid ||= to_s . split ( ":" ) [ 1 ] . to_i
483
+ Process . pid
484
484
end
485
485
486
486
# 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