refactor(server/cron): extra debug info

This commit is contained in:
Linden
2023-08-06 17:36:40 +10:00
parent d12f4845f2
commit 8c9cdb1a13

View File

@@ -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
print(('stopping task %s'):format(self.id))
if msg then
return print(('stopping task %s (%s)'):format(self.id, msg))
end
self.isActive = false
print(('stopping task %s'):format(self.id))
end
end
---@param value string