Software /
code /
prosody
Comparison
plugins/mod_cron.lua @ 11995:bbd3ac65640d
mod_cron: Initialize daily tasks so they run around midnight UTC
Eventually the goal is to have daily tasks run while there is little
activity, but that will vary with the server and the usage patterns of
its users. This is a start anyway.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 03 Dec 2021 00:11:31 +0100 |
parent | 11986:3d5135e8a2a7 |
child | 12000:00c57684cf20 |
comparison
equal
deleted
inserted
replaced
11994:f9b2325f6b50 | 11995:bbd3ac65640d |
---|---|
19 if task.id == nil then task.id = event.source.name .. "/" .. task.name:gsub("%W", "_"):lower(); end | 19 if task.id == nil then task.id = event.source.name .. "/" .. task.name:gsub("%W", "_"):lower(); end |
20 if task.last == nil then task.last = last_run_times:get(nil, task.id); end | 20 if task.last == nil then task.last = last_run_times:get(nil, task.id); end |
21 task.save = save_task; | 21 task.save = save_task; |
22 module:log("debug", "%s task %s added, last run %s", task.when, task.id, | 22 module:log("debug", "%s task %s added, last run %s", task.when, task.id, |
23 task.last and require("util.datetime").datetime(task.last) or "never"); | 23 task.last and require("util.datetime").datetime(task.last) or "never"); |
24 if task.last == nil and task.when == "daily" then | |
25 local now = os.time(); | |
26 task.last = now - now % 86400; | |
27 end | |
24 return true | 28 return true |
25 end | 29 end |
26 | 30 |
27 local function task_removed(event) | 31 local function task_removed(event) |
28 local task = event.item; | 32 local task = event.item; |