mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
refactor(server/cron): extra debug info
This commit is contained in:
@@ -216,14 +216,14 @@ function OxTask:scheduleTask()
|
|||||||
local runAt = self:getNextTime()
|
local runAt = self:getNextTime()
|
||||||
|
|
||||||
if not runAt then
|
if not runAt then
|
||||||
return self:stop()
|
return self:stop('getNextTime returned no value')
|
||||||
end
|
end
|
||||||
|
|
||||||
local currentTime = os.time()
|
local currentTime = os.time()
|
||||||
local sleep = runAt - currentTime
|
local sleep = runAt - currentTime
|
||||||
|
|
||||||
if sleep < 0 then
|
if sleep < 0 then
|
||||||
return self:stop()
|
return self:stop(self.debug and ('scheduled time expired %s seconds ago'):format(-sleep))
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.debug then
|
if self.debug then
|
||||||
@@ -262,12 +262,16 @@ function OxTask:run()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function OxTask:stop()
|
function OxTask:stop(msg)
|
||||||
|
self.isActive = false
|
||||||
|
|
||||||
if self.debug then
|
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))
|
print(('stopping task %s'):format(self.id))
|
||||||
end
|
end
|
||||||
|
|
||||||
self.isActive = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param value string
|
---@param value string
|
||||||
|
|||||||
Reference in New Issue
Block a user