Last active
October 28, 2017 09:32
-
-
Save maztch/47f1ceecd6149da58945910b99865f03 to your computer and use it in GitHub Desktop.
a process count check for php-enqueue/enqueue-bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* It's just a sample helper | |
* I'm sure it can be done better... | |
**/ | |
class QueueHelper | |
{ | |
static public function check(){ | |
$out = []; | |
exec('ps -ef | grep \'enqueue:consume\'', $out); | |
$count = 0; | |
foreach($out as $line){ | |
if(strpos($line, 'grep')===false){ | |
$count++; | |
} | |
} | |
return $count; | |
} | |
static public function run(){ | |
exec('php /var/www/yourproject/bin/console enqueue:consume > /dev/null 2>/dev/null &'); | |
} | |
static public function killAll(){ | |
exec('pkill -f \'php /var/www/yourproject/bin/console enqueue:consume\'', $out); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment