publishers: retry on failure

This commit is contained in:
bergware
2024-01-05 20:22:55 +01:00
parent 86366d4409
commit 26452c82f3
7 changed files with 25 additions and 50 deletions

View File

@@ -17,7 +17,7 @@ $varroot = '/var/local/emhttp';
$pool_log = '/var/tmp/pool_log.tmp';
$smartALL = '/boot/config/smart-all.cfg';
$smartONE = '/boot/config/smart-one.cfg';
$md5_old = $fs_old = $timeout = -1;
$md5_old = $fs_old = -1;
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/publish.php";
@@ -530,16 +530,12 @@ while (true) {
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 15) {
publish('devices', $echo);
$md5_old = $md5_new;
$timeout = -1;
if ($md5_new !== $md5_old) {
$md5_old = publish('devices',$echo)!==false ? $md5_new : -1;
}
$fs_new = _var($var,'fsState')=='Started' ? 1 : 0;
if ($fs_new !== $fs_old) {
publish('arraymonitor', $fs_new);
$fs_old = $fs_new;
$fs_old = publish('arraymonitor',$fs_new)!==false ? $fs_new : -1;
}
sleep(1);
}

View File

@@ -17,7 +17,7 @@ $varroot = '/var/local/emhttp';
$log = '/boot/config/parity-checks.log';
$stamps = '/var/tmp/stamps.ini';
$resync = '/var/tmp/resync.ini';
$md5_old = $spot_old = $fs_old = $proc_old = $timeout = -1;
$md5_old = $spot_old = $fs_old = $proc_old = -1;
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/publish.php";
@@ -116,23 +116,17 @@ while (true) {
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 60) {
publish('parity', $echo);
$md5_old = $md5_new;
$timeout = -1;
if ($md5_new !== $md5_old) {
$md5_old = publish('parity',$echo)!==false ? $md5_new : -1;
}
if ($spot !== $spot_old) {
publish('paritymonitor', $spot>0 ? 1 : 0);
$spot_old = $spot;
$spot_old = publish('paritymonitor',$spot>0 ? 1 : 0)!==false ? $spot : -1;
}
if ($fsState !== $fs_old) {
publish('fsState', $fsState);
$fs_old = $fsState;
$fs_old = publish('fsState',$fsState)!==false ? $fsState : -1;
}
if ($process !== $proc_old) {
publish('mymonitor', $process);
$proc_old = $process;
$proc_old = publish('mymonitor',$process)!==false ? $process : -1;
}
sleep(1);
}

View File

@@ -14,7 +14,7 @@
<?
$docroot = '/usr/local/emhttp';
$varroot = '/var/local/emhttp';
$md5_old = $timeout = -1;
$md5_old = -1;
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/publish.php";
@@ -98,11 +98,8 @@ while (true) {
foreach ($share as $name) $echo['stream'][] = $count[$name]??0;
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 12) {
publish('update1', $echo);
$md5_old = $md5_new;
$timeout = -1;
if ($md5_new !== $md5_old) {
$md5_old = publish('update1',$echo)!==false ? $md5_new : -1;
}
sleep(5);
}

View File

@@ -16,7 +16,7 @@ $docroot = '/usr/local/emhttp';
$varroot = '/var/local/emhttp';
$stamps = '/var/tmp/stamps.ini';
$resync = '/var/tmp/resync.ini';
$md5_old = $timeout = -1;
$md5_old = -1;
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/publish.php";
@@ -470,11 +470,8 @@ while (true) {
}
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 30) {
publish('update2', $echo);
$md5_old = $md5_new;
$timeout = -1;
if ($md5_new !== $md5_old) {
$md5_old = publish('update2',$echo)!==false ? $md5_new : -1;
}
sleep(2);
}

View File

@@ -15,7 +15,7 @@
$docroot = '/usr/local/emhttp';
$net = '/sys/class/net';
$bond = '/proc/net/bonding';
$md5_old = $timeout = -1;
$md5_old = -1;
$data = [];
require_once "$docroot/webGui/include/Helpers.php";
@@ -137,12 +137,9 @@ while (true) {
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 60) {
publish('update3', $echo);
$md5_old = $md5_new;
if ($md5_new !== $md5_old) {
$md5_old = publish('update3',$echo)!==false ? $md5_new : -1;
$time0 = $time1;
$timeout = -1;
}
sleep(1);
$time1 = microtime(true);

View File

@@ -25,7 +25,7 @@ require_once "$docroot/webGui/include/Translations.php";
// remember current language
$locale_init = $locale;
$md5_old = $timeout = -1;
$md5_old = -1;
$state = [
'ONLINE' => _('Online'),
'SLAVE' => '('._('slave').')',
@@ -123,11 +123,8 @@ while (true) {
}
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 20) {
publish('apcups', $echo);
$md5_old = $md5_new;
$timeout = -1;
if ($md5_new !== $md5_old) {
$md5_old = publish('apcups',$echo)!==false ? $md5_new : -1;
}
sleep(3);
}

View File

@@ -27,7 +27,7 @@ function my_scale($value, &$unit) {
return number_format($value, $decimals, '.', $value>9999 ? ',':'');
}
$md5_old = $timeout = -1;
$md5_old = -1;
while (true) {
$now = time();
$echo = [];
@@ -39,11 +39,8 @@ while (true) {
}
$echo = json_encode($echo);
$md5_new = md5($echo,true);
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 60) {
publish('wireguard', $echo);
$md5_old = $md5_new;
$timeout = -1;
if ($md5_new !== $md5_old) {
$md5_old = publish('wireguard',$echo)!==false ? $md5_new : -1;
}
sleep(1);
}