Fix: nchan script monitoring for Main

This commit is contained in:
Squidly271
2025-08-12 21:39:32 -04:00
parent 22abfc6a5c
commit 4e733f971e
3 changed files with 19 additions and 23 deletions

View File

@@ -506,6 +506,11 @@ setTimeout(function(){paritymonitor.start();},5000);
<?endif;?>
$(function(){
// Create dummy listeners for parity monitor and device info to monitor for listeners
var mainPingListener = new NchanSubscriber('/sub/mainPingListener',{subscriber:'websocket', reconnectTimeout:5000});
mainPingListener.on('message', function(msg){});
mainPingListener.start();
var form = document.arrayOps;
if (form.input !== undefined) selectInput(form);
toggle_diskio(true);

View File

@@ -566,15 +566,13 @@ while (true) {
$echo['stop'] = _var($var,'fsState')=='Stopped' ? 1 : 0;
$echo = json_encode($echo);
$md5_new = md5($echo,true);
// if ($md5_new !== $md5_old) {
$md5_old = publish('devices',$echo)!==false ? $md5_new : -1;
// }
// publish without a timeout for no listeners
publish_noDupe('devices',$echo,1,false);
$fs_new = _var($var,'fsState')=='Started' ? 1 : 0;
// if ($fs_new !== $fs_old) {
$fs_old = publish('arraymonitor',$fs_new)!==false ? $fs_new : -1;
// }
publish_noDupe('arraymonitor',$fs_new,1,false);
//publish to the dummy listener with the timeout to see if there are any subscribers
publish_noDupe('mainPingListener',"ping");
sleep(1);
}
?>

View File

@@ -147,21 +147,14 @@ while (true) {
$process = 0;
}
/* Publish changes */
$echo = json_encode($echo);
$md5_new = md5($echo, true);
if ($md5_new !== $md5_old) {
$md5_old = publish('parity', $echo) !== false ? $md5_new : -1;
}
if ($spot !== $spot_old) {
$spot_old = publish('paritymonitor', $spot > 0 ? 1 : 0) !== false ? $spot : -1;
}
if ($fsState !== $fs_old) {
$fs_old = publish('fsState', $fsState) !== false ? $fsState : -1;
}
if ($process !== $proc_old) {
$proc_old = publish('mymonitor', $process) !== false ? $process : -1;
}
// publish without a timeout for no listeners
publish_noDupe('parity', $echo,1,false);
publish_noDupe('paritymonitor', $spot > 0 ? 1 : 0,1,false);
publish_noDupe('fsState', $fsState,1,false);
publish_noDupe('mymonitor', $process,1,false);
//publish to the dummy listener with the timeoutto see if there are any subscribers
publish_noDupe('mainPingListener',"ping");
sleep(3);
}