From 83868504d7b59169b1163d85e4a72e6bc20744ea Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Fri, 29 Dec 2023 10:04:05 +0100 Subject: [PATCH] Super-optimized it; made it a bit more verbose and clearer --- web/clitools/peerscrawl.php | 207 ++++++++++++++++++++++-------------- 1 file changed, 126 insertions(+), 81 deletions(-) diff --git a/web/clitools/peerscrawl.php b/web/clitools/peerscrawl.php index 5a849eb..8b5b1b0 100755 --- a/web/clitools/peerscrawl.php +++ b/web/clitools/peerscrawl.php @@ -16,7 +16,7 @@ along with this program. If not, see . */ -define('N',"\n"); +const N="\n"; define('SNAME',basename(__FILE__)); define('BNAME',preg_replace('/\.[^.]*$/','',SNAME)); @@ -32,11 +32,11 @@ $opts=[ 'inifp'=>__DIR__.'/../conf/mustard.ini', 'startinst'=>'mastodon.social', 'gracetime'=>$gracetime, - 'peersfp'=>__DIR__.'/peers', - 'cpeersfp'=>__DIR__.'/peers.checked', + 'peersfp'=>__DIR__.'/peers.responding', + 'ckpeersfp'=>__DIR__.'/peers.checked', 'excludefp'=>null, - 'timeout'=>8, - 'curltimeout'=>15, + 'conntimeout'=>5, + 'functimeout'=>10, 'loop'=>false, 'excludedead'=>true, 'ignorelock'=>false, @@ -45,8 +45,6 @@ $opts=[ $msglevs=['Debug', 'Info', 'Warning', 'Error', 'None']; -$ghtsa=[[' day',' days'],[' hour',' hours'],[' minute',' minutes'],[' second',' seconds']]; - $help='SYNOPSIS '.SNAME.' [options] @@ -70,7 +68,7 @@ OPTIONS If an instance has not been responding for longer than this time, avoid checking it. See section «TIME SPECIFICATION» below to see how to specify time. - DEFAULT: '.ght($opts['gracetime'],$ghtsa).' + DEFAULT: '.ght($opts['gracetime'],null,0).' -G, --graceline Return the “graceline” (now - gracetime: see option above) in unix time and local time, then exit. @@ -78,22 +76,22 @@ OPTIONS Defines the file into which the ordered list of responding instances will be saved. DEFAULT: «'.$opts['peersfp'].'» - -c, --cpeersfp + -c, --ckpeersfp Defines the file into which the ordered list of all checked instances will be saved. - DEFAULT: «'.$opts['cpeersfp'].'» + DEFAULT: «'.$opts['ckpeersfp'].'» -I, --ignorelock Normally, if its lockfile exists, the program exits with an error before doing anything. With this option the lockfile is ignored. Please verify that the program is not already running before using it. - -t, --timeout