pezcurrel 4 years ago
parent
commit
a594fc7745
2 changed files with 15 additions and 13 deletions
  1. 1 1
      web/mustard/crawler/crawl.sh
  2. 14 12
      web/mustard/crawler/peerscrawl.php

+ 1 - 1
web/mustard/crawler/crawl.sh

@@ -1,4 +1,4 @@
 #!/bin/sh
 BASEDIR=$(dirname $0)
 cd "$BASEDIR"
-php peerscrawl.php && php crawler.php
+php peerscrawl.php -e peerscrawl.exclude && php crawler.php

+ 14 - 12
web/mustard/crawler/peerscrawl.php

@@ -98,25 +98,27 @@ function mexit($msg,$code) {
 	exit($code);
 }
 
-function shutdown() {
+function shutdown($dosort) {
 	global $opts, $peersf, $insts;
 	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);
 function signalHandler($signal) {
 	echo(N.'I got interrupted (signal: '.$signal.').'.N);
-	shutdown();
+	shutdown(false);
 	exit(2);
 }
 pcntl_signal(SIGTERM,'signalHandler');// Termination ('kill' was called)
@@ -239,7 +241,7 @@ function crawl($inst) {
 
 crawl($opts['startinst']);
 echo('DONE CRAWLING! :-)'.N);
-shutdown();
+shutdown(true);
 exit(0);
 
 ?>