Changed a bit how option “jsonwrite” works; other minor changes

This commit is contained in:
pezcurrel 2022-12-16 19:25:45 +01:00
parent f193bd294c
commit 2d31b7ca79

View file

@ -47,12 +47,11 @@ if (function_exists('pcntl_signal')) {
$opts=[
'hostname'=>null,
'timeout'=>10,
'deadline'=>60*24*60*60,// if an instance has not been responding for more than this value of seconds (currently 60 days), declare it dead
'oldline'=>30*24*60*60,// if an instance has been new for a period longer than this amount (currently 30 days), it's no longer new
'deadline'=>60*24*60*60,// if an instance has not been responding for more than this value of seconds, declare it dead
'oldline'=>30*24*60*60,// if an instance has been new for a period longer than this amount, it's no longer new
'ldtoots'=>40,// number of toots to check with the automatic language detection function
'setnew'=>true,
'dryrun'=>false,
'jsonfp'=>__DIR__.'/run/instance.json',
'jsonwrite'=>false,
'fetchusers'=>false,
'udiratts'=>3,
@ -110,11 +109,11 @@ OPTIONS
-d, --dryrun
If this option is set, the script wont write anything in the database.
-j, --jsonwrite
If this option is set, the script will write an «instance.json» file
containing all the data it could retrieve from the considered instance.
If this option is set, the script will write all the JSON data it could
fetch from the considered instance into «run/[instance hostname].json» file.
-L, --logminlev <«debug»|«info»|«warning»|«error»|«none»>
Defines the minimum “importance level” of messages to be written into the
log file «run/[instance_hostname].log». There are 4 “importance levels”, in
log file «run/[instance hostname].log». There are 4 “importance levels”, in
this order of importance: «debug», «info», «warning», «error».
Setting this option to any of these values will write into the logfile all
the messages with the specified or a greater level; setting it to the
@ -221,8 +220,9 @@ $tables=tables($link);
*/
if ($opts['jsonwrite']) {
$jsonf=@fopen($opts['jsonfp'],'w')
or mexit('could not open file «'.$opts['jsonfp'].'» in write mode.',1);
$jsonfp=__DIR__.'/'.$opts['hostname'].'.json';
$jsonf=@fopen($jsonfp,'w')
or mexit('could not open file «'.$jsonfp.'» in write mode.',1);
fwrite($jsonf,'{'.N);
}