diff options
author | Christian Hofmaier | 2021-03-16 20:03:58 +0100 |
---|---|---|
committer | Christian Hofmaier | 2021-03-16 20:03:58 +0100 |
commit | 834b95629832fc3735756727b6c7cb1826d0e9d8 (patch) | |
tree | ff465ef0063c59d92f8c77e89f15a2a7a2405977 /modules-available/rebootcontrol/hooks | |
parent | [sysconfig] yes -> true (diff) | |
download | slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.tar.gz slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.tar.xz slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.zip |
[rebootcontrol] Handle scheduler overlaps
- Overlaps < 5 min are ignored, < 15 triggers reboot
- Database: Make 1 line out of 2
Diffstat (limited to 'modules-available/rebootcontrol/hooks')
-rw-r--r-- | modules-available/rebootcontrol/hooks/cron.inc.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php index 3651c779..9c6cbaaf 100644 --- a/modules-available/rebootcontrol/hooks/cron.inc.php +++ b/modules-available/rebootcontrol/hooks/cron.inc.php @@ -14,10 +14,11 @@ if (in_array((int)date('G'), [6, 7, 9, 12, 15]) && in_array(date('i'), ['00', '0 $now = time(); $res = Database::simpleQuery("SELECT * FROM reboot_scheduler WHERE nextexecution < :now", ['now' => $now]); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $options = json_decode($row['options'], true); // Calculate next_execution for the event. $location = Database::queryFirst("SELECT openingtime FROM `location` WHERE locationid = :lid", array('lid' => $row['locationid'])); - Scheduler::updateSchedule($row['locationid'], $row['action'], $row['options'], $location['openingtime']); + Scheduler::updateSchedule($row['locationid'], $options, $location['openingtime']); if ($row['nextexecution'] + 1200 < $now) continue; @@ -27,10 +28,9 @@ while ($row = $res->fetch(PDO::FETCH_ASSOC)) { settype($machine['locationid'], 'int'); $machines[] = $machine; } - // Options not yet used. - $options = json_decode($row['options']); if ($row['action'] === 'sd') RebootControl::execute($machines, RebootControl::SHUTDOWN, 0); else if ($row['action'] === 'wol') RebootControl::wakeMachines($machines); + else if ($row['action'] === 'rb') RebootControl::execute($machines, RebootControl::REBOOT, 0); } /* |