30 lines
634 B
PHP
30 lines
634 B
PHP
|
#!/opt/local/bin/php
|
||
|
<?php
|
||
|
|
||
|
chdir('../..');
|
||
|
require_once 'common.php';
|
||
|
|
||
|
$workers = json_decode(file_get_contents('/www/parser_data/pid'));
|
||
|
if (!$workers) {
|
||
|
$workers = array('html_grabber' => array(), 'curl_mtgrabber' => array());
|
||
|
}
|
||
|
|
||
|
switch ($argv[1]) {
|
||
|
case 'add':
|
||
|
shell_exec("./worker_". $argv[2] .".php > /www/parse.log &");
|
||
|
break;
|
||
|
case 'remove':
|
||
|
if (isset($workers[$argv[2]]) && count($workers[$argv[2]]) > 0) {
|
||
|
$pid = $workers[$argv[2]][0];
|
||
|
shell_exec("kill $pid");
|
||
|
}
|
||
|
case 'status':
|
||
|
|
||
|
case 'list':
|
||
|
foreach($workers as $type => $pids) {
|
||
|
echo "$type: ". count($pids) ."\n";
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|