summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/bin/scheduler.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/server/bin/scheduler.js b/server/bin/scheduler.js
index dab37a4..e9adf1b 100644
--- a/server/bin/scheduler.js
+++ b/server/bin/scheduler.js
@@ -3,6 +3,7 @@ const path = require('path')
global.__appdir = path.join(__dirname, '..')
const db = require(path.join(__appdir, 'lib', 'sequelize'))
const groupHelper = require(path.join(__appdir, 'lib', 'grouphelper'))
+const { Schedule } = require(path.join(__appdir, 'lib', 'eventhelper'))
const wolHelper = require(path.join(__appdir, 'lib', 'wolhelper'))
const setTimeoutAt = require('safe-timers').setTimeoutAt
const zmq = require('zeromq')
@@ -44,17 +45,11 @@ async function calcNextWake (id) {
}, nextWake)
}
} else {
- return false
- /*
- // 1. Calculate next wake
- nextWake = 99999999999
-
- // 2. Set timeout
- runningTimeouts[id] = setTimeout(function () {
+ nextWake = (new Schedule(event)).next()
+ runningTimeouts[id] = setTimeoutAt(function () {
wakeUpClients(id)
calcNextWake(id)
}, nextWake)
- */
}
if (nextWake > now) console.log('Scheduled event ' + event.name + ' at ' + nextWake)
}
@@ -82,4 +77,6 @@ async function wakeUpClients (id) {
// 2. Wake all clients
wolHelper.wakeUp(clients)
+
+ console.log("Waking up clients. Event: " + event.name)
}