From 2a1d6aa2ae8d824b06c42709a791f2d0787f29e3 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:47:27 +1100 Subject: [PATCH] refactor(server/cron): run jobs in a new thread Better for error handling. --- imports/cron/server.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/imports/cron/server.lua b/imports/cron/server.lua index 632460f..cb6b6f6 100644 --- a/imports/cron/server.lua +++ b/imports/cron/server.lua @@ -238,12 +238,14 @@ function OxTask:scheduleTask() end if self.isActive then - self:job(currentDate) - if self.debug then - print(('(%s/%s/%s %s:%s) ran task %s'):format(currentDate.year, currentDate.month, currentDate.day, currentDate.hour, currentDate.min, self.id)) + print(('(%s/%s/%s %s:%s) running task %s'):format(currentDate.year, currentDate.month, currentDate.day, currentDate.hour, currentDate.min, self.id)) end + Citizen.CreateThreadNow(function() + self:job(currentDate) + end) + Wait(30000) return true