diff options
author | Simon Rettberg | 2024-09-07 19:30:56 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-09-07 19:30:56 +0200 |
commit | c6cd1d0b305a665ac948bafaaec9dfd35fdd973a (patch) | |
tree | 98e0513eff9216fa4524b30b81d9b56a659c65cd /modules-available | |
parent | [sysconfig] Change sort order of loginscreen: lower (diff) | |
download | slx-admin-c6cd1d0b305a665ac948bafaaec9dfd35fdd973a.tar.gz slx-admin-c6cd1d0b305a665ac948bafaaec9dfd35fdd973a.tar.xz slx-admin-c6cd1d0b305a665ac948bafaaec9dfd35fdd973a.zip |
[rebootcontrol] Only run the Taskmanager check if we got work to do
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/rebootcontrol/hooks/cron.inc.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php index 289426c7..287f58bc 100644 --- a/modules-available/rebootcontrol/hooks/cron.inc.php +++ b/modules-available/rebootcontrol/hooks/cron.inc.php @@ -179,13 +179,19 @@ foreach ($res as $row) { } unset($res); -$task = Taskmanager::submit('DummyTask', []); -$task = Taskmanager::waitComplete($task, 4000); -if (!Taskmanager::isFinished($task)) { - cron_log('Task manager down. Doing nothing.'); - return; // No :-( +function checkTmUp() +{ + static $done = false; + if ($done) + return; + $done = true; + $task = Taskmanager::submit('DummyTask', []); + $task = Taskmanager::waitComplete($task, 4000); + if (!Taskmanager::isFinished($task)) { + cron_log('TaskManager down. Doing nothing.'); + exit; // No :-( + } } -unset($task); /* * Try server to client @@ -194,8 +200,10 @@ unset($task); $res = Database::simpleQuery("SELECT subnetid FROM reboot_subnet WHERE subnetid IN (:active) AND nextdirectcheck < UNIX_TIMESTAMP() AND fixed = 0 ORDER BY nextdirectcheck ASC LIMIT 10", ['active' => array_keys(Stuff::$subnets)]); + cron_log('Direct checks: ' . $res->rowCount() . ' (' . implode(', ', array_keys(Stuff::$subnets)) . ')'); foreach ($res as $row) { + checkTmUp(); $dst = (int)$row['subnetid']; cron_log('Direct check for subnetid ' . $dst); $result = testServerToClient($dst); @@ -241,6 +249,7 @@ if (count($combos) > 0) { LIMIT 10", ['combos' => $combos]); cron_log('C2C checks: ' . $res->rowCount()); foreach ($res as $row) { + checkTmUp(); $src = (int)$row['srcid']; $dst = (int)$row['dstid']; $result = testClientToClient($src, $dst); |