Fixed a bug that was preventing crawler.php and peerscrawl.php to use the actual graceline they should be using when the “--gracetime” option was used

This commit is contained in:
pezcurrel 2024-02-25 09:55:59 +01:00
parent 0db641dc82
commit a611e251fc
3 changed files with 11 additions and 4 deletions

View file

@ -135,6 +135,7 @@ for ($i=1; $i<$argc; $i++) {
$i++;
$opts['gracetime']=$time;
} elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') {
$graceline=getgraceline($opts['gracetime']);
echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N;
exit(0);
} elseif ($argv[$i]=='-p' || $argv[$i]=='--peersfp') {
@ -164,6 +165,7 @@ for ($i=1; $i<$argc; $i++) {
}
}
$graceline=getgraceline($opts['gracetime']);
$rundirpath=__DIR__.'/run';
$lockfp=$rundirpath.'/'.FNAME.'.lock';

View file

@ -163,6 +163,7 @@ for ($i=1; $i<$argc; $i++) {
$i++;
$opts['minmsgimplev']=array_search(ucfirst(strtolower($argv[$i])),$msglevs);
} elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') {
$graceline=getgraceline($opts['gracetime']);
echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N;
exit(0);
} elseif ($argv[$i]=='-h' || $argv[$i]=='--help') {
@ -173,6 +174,8 @@ for ($i=1; $i<$argc; $i++) {
}
}
$graceline=getgraceline($opts['gracetime']);
$lockfp=__DIR__.'/'.BNAME.'.lock';
if (is_file($lockfp) && !$opts['ignorelock']) mexit(3,'lockfile exists: it seems the program is already running; if youre sure its not, you can use «-I» to force execution.'.N,1,false);
if (@touch($lockfp)===false) mexit(3,'could not create lockfile «'.$lockfp.'».'.N,1,false);

View file

@ -2,9 +2,11 @@
$graceminfreq=48*60*60;// 2 days
$gracetime=30*24*60*60;// 30 days
$now=time();
$graceline=gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now))-$gracetime;// we fix the graceline at start of today minus $gracetime
//$graceline=$now-$gracetime;// we fix the graceline at now minus $gracetime
unset($now);
$graceline=getgraceline($gracetime);
function getgraceline($gracetime) {
$now=time();
return gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now))-$gracetime;// we fix the graceline at start of today minus $gracetime
}
?>