1
0
Fork 0
oldhaven/php/bin/parser/handler.php

30 lines
634 B
PHP
Raw Normal View History

2011-04-02 14:57:17 +00:00
#!/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;
}