From 8c9cdb1a13d86bfd92b1edf5ff59b3b49c888117 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:36:40 +1000 Subject: [PATCH] refactor(server/cron): extra debug info --- imports/cron/server.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/imports/cron/server.lua b/imports/cron/server.lua index a059409..dacf375 100644 --- a/imports/cron/server.lua +++ b/imports/cron/server.lua @@ -216,14 +216,14 @@ function OxTask:scheduleTask() local runAt = self:getNextTime() if not runAt then - return self:stop() + return self:stop('getNextTime returned no value') end local currentTime = os.time() local sleep = runAt - currentTime if sleep < 0 then - return self:stop() + return self:stop(self.debug and ('scheduled time expired %s seconds ago'):format(-sleep)) end if self.debug then @@ -262,12 +262,16 @@ function OxTask:run() end) end -function OxTask:stop() +function OxTask:stop(msg) + self.isActive = false + if self.debug then + if msg then + return print(('stopping task %s (%s)'):format(self.id, msg)) + end + print(('stopping task %s'):format(self.id)) end - - self.isActive = false end ---@param value string