Fixed “deadinsts” loading queries; changed default “conntimeout” and “functimeout”
This commit is contained in:
parent
6c29f1e24e
commit
6914551daa
1 changed files with 9 additions and 10 deletions
|
@ -23,7 +23,7 @@ define('BNAME',preg_replace('/\.[^.]*$/','',SNAME));
|
||||||
require __DIR__.'/../lib/gurl.php';
|
require __DIR__.'/../lib/gurl.php';
|
||||||
require __DIR__.'/../lib/ghs.php';
|
require __DIR__.'/../lib/ghs.php';
|
||||||
require __DIR__.'/../lib/ght.php';
|
require __DIR__.'/../lib/ght.php';
|
||||||
require __DIR__.'/../lib/gracetime.php';
|
require __DIR__.'/../lib/grace.php';
|
||||||
require __DIR__.'/../lib/parsetime.php';
|
require __DIR__.'/../lib/parsetime.php';
|
||||||
|
|
||||||
use function mysqli_real_escape_string as myesc;
|
use function mysqli_real_escape_string as myesc;
|
||||||
|
@ -35,8 +35,8 @@ $opts=[
|
||||||
'peersfp'=>__DIR__.'/peers.responding',
|
'peersfp'=>__DIR__.'/peers.responding',
|
||||||
'ckpeersfp'=>__DIR__.'/peers.checked',
|
'ckpeersfp'=>__DIR__.'/peers.checked',
|
||||||
'excludefp'=>null,
|
'excludefp'=>null,
|
||||||
'conntimeout'=>3,
|
'conntimeout'=>4,
|
||||||
'functimeout'=>5,
|
'functimeout'=>7,
|
||||||
'loop'=>false,
|
'loop'=>false,
|
||||||
'excludedead'=>true,
|
'excludedead'=>true,
|
||||||
'ignorelock'=>false,
|
'ignorelock'=>false,
|
||||||
|
@ -73,8 +73,8 @@ OPTIONS
|
||||||
how to specify time.
|
how to specify time.
|
||||||
DEFAULT: '.ght($opts['gracetime'],null,0).'
|
DEFAULT: '.ght($opts['gracetime'],null,0).'
|
||||||
-G, --graceline
|
-G, --graceline
|
||||||
Return the “graceline” (now - gracetime: see option above) in unix time and
|
Return the “graceline” (0:0:0 of today minus gracetime: see option above) in
|
||||||
local time, then exit.
|
unix time and local time, then exit.
|
||||||
-p, --peersfp <file>
|
-p, --peersfp <file>
|
||||||
Defines the file into which the ordered list of responding instances
|
Defines the file into which the ordered list of responding instances
|
||||||
will be saved.
|
will be saved.
|
||||||
|
@ -163,7 +163,6 @@ for ($i=1; $i<$argc; $i++) {
|
||||||
$i++;
|
$i++;
|
||||||
$opts['minmsgimplev']=array_search(ucfirst(strtolower($argv[$i])),$msglevs);
|
$opts['minmsgimplev']=array_search(ucfirst(strtolower($argv[$i])),$msglevs);
|
||||||
} elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') {
|
} elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') {
|
||||||
$graceline=time()-$opts['gracetime'];
|
|
||||||
echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N;
|
echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N;
|
||||||
exit(0);
|
exit(0);
|
||||||
} elseif ($argv[$i]=='-h' || $argv[$i]=='--help') {
|
} elseif ($argv[$i]=='-h' || $argv[$i]=='--help') {
|
||||||
|
@ -199,14 +198,14 @@ if ($res===false) mexit(3,'couldn’t set «utf8mb4» charset for MySQL: '.mysql
|
||||||
|
|
||||||
$deadinsts=[];
|
$deadinsts=[];
|
||||||
if ($opts['excludedead']) {
|
if ($opts['excludedead']) {
|
||||||
$graceline=time()-$opts['gracetime'];
|
|
||||||
lecho(1,'loading dead instances from “Instances” and “Peers” table (gracetime: '.ght($opts['gracetime'],null,0).'; graceline: '.date('Y-m-d H:i:s',$graceline).').'.N);
|
lecho(1,'loading dead instances from “Instances” and “Peers” table (gracetime: '.ght($opts['gracetime'],null,0).'; graceline: '.date('Y-m-d H:i:s',$graceline).').'.N);
|
||||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS<'.$graceline.' OR LastOkCheckTS IS NULL');
|
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS IS NULL OR LastOkCheckTS < '.$graceline);
|
||||||
lecho(1,'got '.mysqli_num_rows($res).' dead instances from “Instances” table.'.N);
|
lecho(1,'got '.mysqli_num_rows($res).' dead instances from “Instances” table.'.N);
|
||||||
while ($row=mysqli_fetch_assoc($res))
|
while ($row=mysqli_fetch_assoc($res))
|
||||||
if (!in_array($row['URI'],$deadinsts))
|
if (!in_array($row['URI'],$deadinsts))
|
||||||
$deadinsts[]=$row['URI'];
|
$deadinsts[]=$row['URI'];
|
||||||
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS<'.$graceline.' OR LastOkCheckTS IS NULL');
|
// $res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS IS NULL OR (LastCheckTS-LastOkCheckTS < '.$gracetime.' AND (LastCheckTS-LastOkCheckTS) / (ChecksAtLast-ChecksAtLastOk) <= '.$graceminfreq.')');
|
||||||
|
$res=myq($link,'SELECT Hostname FROM Peers WHERE LastOkCheckTS IS NULL OR LastOkCheckTS < '.$graceline);
|
||||||
lecho(1,'got '.mysqli_num_rows($res).' dead instances from “Peers” table.'.N);
|
lecho(1,'got '.mysqli_num_rows($res).' dead instances from “Peers” table.'.N);
|
||||||
while ($row=mysqli_fetch_assoc($res))
|
while ($row=mysqli_fetch_assoc($res))
|
||||||
if (!in_array($row['Hostname'],$deadinsts))
|
if (!in_array($row['Hostname'],$deadinsts))
|
||||||
|
@ -214,7 +213,7 @@ if ($opts['excludedead']) {
|
||||||
unset($res,$row);
|
unset($res,$row);
|
||||||
lecho(1,'loaded list of dead instances ('.count($deadinsts).').'.N);
|
lecho(1,'loaded list of dead instances ('.count($deadinsts).').'.N);
|
||||||
}
|
}
|
||||||
//mexit(0,'bau!'.N,0,true);
|
//mexit(1,'bau!'.N,0,true);
|
||||||
|
|
||||||
$insts=[];
|
$insts=[];
|
||||||
$ckinsts=[];
|
$ckinsts=[];
|
||||||
|
|
Loading…
Reference in a new issue