Merge pull request #1573 from bergware/master

device_list: add timeout to force update
This commit is contained in:
tom mortensen
2024-01-04 09:19:51 -08:00
committed by GitHub
2 changed files with 26 additions and 3 deletions

View File

@@ -17,8 +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 = -1;
$fs_old = -1;
$md5_old = $fs_old = $timeout = -1;
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/publish.php";
@@ -531,9 +530,11 @@ while (true) {
$echo = json_encode($echo);
$md5_new = md5($echo,true);
if ($md5_new !== $md5_old) {
$timeout++;
if ($md5_new !== $md5_old || $timeout >= 15) {
publish('devices', $echo);
$md5_old = $md5_new;
$timeout = -1;
}
$fs_new = _var($var,'fsState')=='Started' ? 1 : 0;
if ($fs_new !== $fs_old) {

View File

@@ -6,6 +6,28 @@ nginx=/var/run/nginx.socket # nginx local access
status=http://localhost/pub/session?buffer_length=1 # nchan information about GUI subscribers
nchan_id=$(basename "$0")
# immediate kill command
if [[ $1 == kill ]]; then
[[ -e $nchan_pid ]] || exit
echo "Killing nchan processes..."
while IFS=$'\n' read -r running; do
name="${running##*/}"
# kill all processes or single process
if [[ -z $2 || $2 == ${name/:stop/} ]]; then
echo "$name"
pkill -f "$docroot/${running/:stop/}"
fi
done < $nchan_pid
if [[ -z $2 ]]; then
# remove pid file
rm -f $nchan_pid $disk_load
else
# remove single entry
sed -i "/$2/d" $nchan_pid
fi
exit
fi
while :; do
# only act when GUI registered nchan processes are running
if [[ -e $nchan_pid ]]; then