mirror of
https://github.com/unraid/webgui.git
synced 2026-05-04 16:59:27 -05:00
Revamp services management
Put update requests in a job queue and replace the job queue when new update requests are presented within the scheduled wait time This approach makes only the last update request running New log entries are provided to follow execution of the jobs
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
#!/bin/bash
|
||||
SERVICES="rpc nfsd ntpd nginx sshd avahidaemon samba"
|
||||
|
||||
if [[ -n $1 ]]; then
|
||||
[[ ! -e $1 ]] && touch $1 || exit 0
|
||||
# delayed execution
|
||||
sleep ${1:-1}
|
||||
|
||||
# run & log functions
|
||||
. /etc/rc.d/rc.runlog
|
||||
|
||||
JOB=$(atq | grep -Pom1 '^\d+')
|
||||
if [[ -n $JOB ]]; then
|
||||
atrm $JOB 2>/dev/null
|
||||
log "execute queued job $JOB"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for cmd in $SERVICES; do
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#!/bin/bash
|
||||
lock=/tmp/atlock.tmp
|
||||
|
||||
# run & log functions
|
||||
. /etc/rc.d/rc.runlog
|
||||
|
||||
log "delay = ${1:-1}s"
|
||||
rm -f $lock
|
||||
echo "sleep ${1:-1};/usr/local/emhttp/webGui/scripts/reload_services $lock"|at -M now &>/dev/null
|
||||
JOB=$(atq | grep -Pom1 '^\d+')
|
||||
if [[ -n $JOB ]]; then
|
||||
atrm $JOB 2>/dev/null
|
||||
log "remove queued job $JOB"
|
||||
else
|
||||
log "no queued job present"
|
||||
fi
|
||||
|
||||
echo "/usr/local/emhttp/webGui/scripts/reload_services ${1:-1}" | at -M now 2>/dev/null
|
||||
log "queue new job $(atq | grep -Pom1 '^\d+'), wait for ${1:-1}s"
|
||||
exit 0
|
||||
|
||||
@@ -27,7 +27,7 @@ if ($arg == 'yes') {
|
||||
exec("/etc/rc.d/rc.wireless start &>/dev/null &");
|
||||
} elseif ($arg == 'no') {
|
||||
exec("/etc/rc.d/rc.wireless stop");
|
||||
exec("$docroot/webGui/scripts/update_services 5");
|
||||
exec("$docroot/webGui/scripts/update_services");
|
||||
} elseif (($wifi['wlan0']['WIFI']??'') == 'yes') {
|
||||
foreach ($wifi as $network => $block) {
|
||||
if ($network == $port) continue;
|
||||
|
||||
Reference in New Issue
Block a user