Skip to content

Commit 34de8e4

Browse files
author
chris.boulton
committed
Add PIDFILE environment variable to write the PID of a single running worker out to a file
1 parent 0372a27 commit 34de8e4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

resque.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
}
66

77
$APP_INCLUDE = getenv('APP_INCLUDE');
8-
if(!$APP_INCLUDE) {
8+
if($APP_INCLUDE) {
99
if(!file_exists($APP_INCLUDE)) {
1010
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
1111
}
@@ -66,6 +66,13 @@
6666
$queues = explode(',', $QUEUE);
6767
$worker = new Resque_Worker($queues);
6868
$worker->logLevel = $logLevel;
69+
70+
$PIDFILE = getenv('PIDFILE');
71+
if ($PIDFILE) {
72+
file_put_contents($PIDFILE, getmypid()) or
73+
die('Could not write PID information to ' . $PIDFILE);
74+
}
75+
6976
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
7077
$worker->work($interval);
7178
}

0 commit comments

Comments
 (0)