Skip to content

Instantly share code, notes, and snippets.

@maztch
Last active October 28, 2017 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maztch/47f1ceecd6149da58945910b99865f03 to your computer and use it in GitHub Desktop.
Save maztch/47f1ceecd6149da58945910b99865f03 to your computer and use it in GitHub Desktop.
a process count check for php-enqueue/enqueue-bundle
<?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