Integrated and fixed gracetime/graceline logic
This commit is contained in:
parent
618ebfa54b
commit
b9ab074e1c
1 changed files with 6 additions and 9 deletions
|
@ -23,7 +23,7 @@ define('CHILD','getinstinfo.php');
|
|||
define('LIBDP','/../lib');
|
||||
|
||||
require __DIR__.LIBDP.'/ght.php';
|
||||
require __DIR__.LIBDP.'/gracetime.php';
|
||||
require __DIR__.LIBDP.'/grace.php';
|
||||
require __DIR__.LIBDP.'/parsetime.php';
|
||||
|
||||
use function mysqli_real_escape_string as myesc;
|
||||
|
@ -71,8 +71,8 @@ OPTIONS
|
|||
time.
|
||||
DEFAULT: '.ght($opts['gracetime'],null,0).'
|
||||
-G, --graceline
|
||||
Return the “graceline” (now - gracetime: see option above) in unix time and
|
||||
local time, then exit.
|
||||
Return the “graceline” (0:0:0 of today minus gracetime: see option above) in
|
||||
unix time and local time, then exit.
|
||||
-p, --peersfp <file>
|
||||
Defines the path to a file containing a list of instances to consider in
|
||||
addition to those which are already present in the database. Note that this
|
||||
|
@ -135,8 +135,7 @@ for ($i=1; $i<$argc; $i++) {
|
|||
$i++;
|
||||
$opts['gracetime']=$time;
|
||||
} 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);
|
||||
} elseif ($argv[$i]=='-p' || $argv[$i]=='--peersfp') {
|
||||
if ($i+1>=$argc || !file_exists($argv[$i+1]) || !is_file($argv[$i+1]) || !is_readable($argv[$i+1]))
|
||||
|
@ -165,8 +164,6 @@ for ($i=1; $i<$argc; $i++) {
|
|||
}
|
||||
}
|
||||
|
||||
$graceline=time()-$opts['gracetime'];
|
||||
|
||||
$rundirpath=__DIR__.'/run';
|
||||
|
||||
$lockfp=$rundirpath.'/'.FNAME.'.lock';
|
||||
|
@ -241,7 +238,7 @@ if ($restore) {
|
|||
|
||||
$insts=[];
|
||||
eecho(0,'loading instances from the database...'.N);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS>='.$graceline.' OR (LastOkCheckTS IS NULL AND InsertTS>='.$graceline.')',__LINE__);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS IS NOT NULL AND LastOkCheckTS>='.$graceline,__LINE__);
|
||||
while($row=mysqli_fetch_assoc($res))
|
||||
if (!in_array($row['URI'],$insts))
|
||||
$insts[]=$row['URI'];
|
||||
|
@ -249,7 +246,7 @@ if ($restore) {
|
|||
|
||||
if (!is_null($opts['peersfp'])) {
|
||||
eecho(0,'loading “dead” instances from the database...'.N);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS<'.$graceline.' OR (LastOkCheckTS IS NULL AND InsertTS<'.$graceline.')',__LINE__);
|
||||
$res=myq($link,'SELECT URI FROM Instances WHERE LastOkCheckTS IS NULL OR LastOkCheckTS<'.$graceline,__LINE__);
|
||||
$deadinsts=[];
|
||||
while($row=mysqli_fetch_assoc($res))
|
||||
if (!in_array($row['URI'],$deadinsts))
|
||||
|
|
Loading…
Reference in a new issue