|
@@ -98,25 +98,27 @@ function mexit($msg,$code) {
|
|
exit($code);
|
|
exit($code);
|
|
}
|
|
}
|
|
|
|
|
|
-function shutdown() {
|
|
|
|
|
|
+function shutdown($dosort) {
|
|
global $opts, $peersf, $insts;
|
|
global $opts, $peersf, $insts;
|
|
if ($peersf) @fclose($peersf);
|
|
if ($peersf) @fclose($peersf);
|
|
- echo('Saving ordered instances list into «'.$opts['peersfp'].'».'.N);
|
|
|
|
- sort($insts);
|
|
|
|
- $peersf=@fopen($opts['peersfp'],'w');
|
|
|
|
- if ($peersf!==false) {
|
|
|
|
- foreach ($insts as $inst)
|
|
|
|
- fwrite($peersf,$inst.N);
|
|
|
|
- fclose($peersf);
|
|
|
|
- } else {
|
|
|
|
- echo('Couldn’t open «'.$opts['peersfp'].'» for writing.'.N);
|
|
|
|
|
|
+ if ($dosort) {
|
|
|
|
+ echo('Saving ordered instances list into «'.$opts['peersfp'].'».'.N);
|
|
|
|
+ sort($insts);
|
|
|
|
+ $peersf=@fopen($opts['peersfp'],'w');
|
|
|
|
+ if ($peersf!==false) {
|
|
|
|
+ foreach ($insts as $inst)
|
|
|
|
+ fwrite($peersf,$inst.N);
|
|
|
|
+ fclose($peersf);
|
|
|
|
+ } else {
|
|
|
|
+ echo('Couldn’t open «'.$opts['peersfp'].'» for writing.'.N);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
declare(ticks=1);
|
|
declare(ticks=1);
|
|
function signalHandler($signal) {
|
|
function signalHandler($signal) {
|
|
echo(N.'I got interrupted (signal: '.$signal.').'.N);
|
|
echo(N.'I got interrupted (signal: '.$signal.').'.N);
|
|
- shutdown();
|
|
|
|
|
|
+ shutdown(false);
|
|
exit(2);
|
|
exit(2);
|
|
}
|
|
}
|
|
pcntl_signal(SIGTERM,'signalHandler');// Termination ('kill' was called)
|
|
pcntl_signal(SIGTERM,'signalHandler');// Termination ('kill' was called)
|
|
@@ -239,7 +241,7 @@ function crawl($inst) {
|
|
|
|
|
|
crawl($opts['startinst']);
|
|
crawl($opts['startinst']);
|
|
echo('DONE CRAWLING! :-)'.N);
|
|
echo('DONE CRAWLING! :-)'.N);
|
|
-shutdown();
|
|
|
|
|
|
+shutdown(true);
|
|
exit(0);
|
|
exit(0);
|
|
|
|
|
|
?>
|
|
?>
|