fixed bot retire\add all
This commit is contained in:
parent
fcdaf458cd
commit
134873e50c
|
@ -8,6 +8,7 @@ $bots = array();
|
|||
foreach ($tmp as $bfile) {
|
||||
$bots[str_replace('.json', '', $bfile)] = json_decode(file_get_contents(Config::get('app:Parser:bot_stats_dir').$bfile));
|
||||
}
|
||||
|
||||
foreach ($bots as $name => $bot) {
|
||||
$tmp = exec("ps ".$bot->pid);
|
||||
$bot->active = (int) (strpos($tmp, strval($bot->pid)) !== false);
|
||||
|
@ -35,22 +36,17 @@ switch ($argv[1]) {
|
|||
if (!$bot->active) {
|
||||
echo "Launching ". $name ."\n";
|
||||
shell_exec(ROOT_DIR ."/bin/parser/worker_html_grabber.php ". $name ." > /www/parser_data/log/". $name .".log &");
|
||||
die;
|
||||
if ($bot_name != 'All') {
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "All bots are working already\n";
|
||||
echo "All bots are working.\n";
|
||||
}
|
||||
break;
|
||||
case 'retire':
|
||||
$bot_name = (isset($argv[2]) ? ucfirst($argv[2]) : false);
|
||||
if ($bot_name == 'all') {
|
||||
foreach ($bots as $name => $bot) {
|
||||
if ($bot->active) {
|
||||
echo "Stopping ". $name ."\n";
|
||||
shell_exec("kill ". $bot->pid);
|
||||
}
|
||||
}
|
||||
} elseif ($bot_name && isset($bots[$bot_name])) {
|
||||
if ($bot_name && isset($bots[$bot_name])) {
|
||||
$bot = $bots[$bot_name];
|
||||
if(!$bot->active) {
|
||||
echo $bot_name ." is not working now\n";
|
||||
|
@ -64,10 +60,12 @@ switch ($argv[1]) {
|
|||
if ($bot->active) {
|
||||
echo "Stopping ". $name ."\n";
|
||||
shell_exec("kill ". $bot->pid);
|
||||
die;
|
||||
if ($bot_name != 'All') {
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "All bots are working already\n";
|
||||
echo "All bots are stopped.\n";
|
||||
}
|
||||
break;
|
||||
case 'list':
|
||||
|
|
Loading…
Reference in New Issue