Skip to content

Commit 0b0f9dc

Browse files
Make workerPids() work on Windows using WMIC instead of ps
1 parent cd85e8b commit 0b0f9dc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/Resque/Worker.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,18 @@ public function pruneDeadWorkers()
441441
public function workerPids()
442442
{
443443
$pids = array();
444-
exec('ps -A -o pid,command | grep [r]esque', $cmdOutput);
445-
foreach($cmdOutput as $line) {
446-
list($pids[],) = explode(' ', trim($line), 2);
444+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
445+
exec('WMIC path win32_process get Processid,Commandline | findstr resque | findstr /V findstr', $cmdOutput);
446+
foreach($cmdOutput as $line) {
447+
$line = preg_replace('/\s+/m', ' ', $line);
448+
list(,,$pids[]) = explode(' ', trim($line), 3);
449+
}
450+
}
451+
else {
452+
exec('ps -A -o pid,command | grep [r]esque', $cmdOutput);
453+
foreach($cmdOutput as $line) {
454+
list($pids[],) = explode(' ', trim($line), 2);
455+
}
447456
}
448457
return $pids;
449458
}

0 commit comments

Comments
 (0)