Comparison

teal-src/plugins/mod_cron.tl @ 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
52 task.last = last_run_times:get(nil, task.id); 52 task.last = last_run_times:get(nil, task.id);
53 end 53 end
54 task.save = save_task; 54 task.save = save_task;
55 module:log("debug", "%s task %s added, last run %s", task.when, task.id, 55 module:log("debug", "%s task %s added, last run %s", task.when, task.id,
56 task.last and require"util.datetime".datetime(task.last) or "never"); 56 task.last and require"util.datetime".datetime(task.last) or "never");
57 if task.last == nil and task.when == "daily" then
58 -- initialize daily tasks to run at ~midnight UTC for now
59 local now = os.time();
60 task.last = now - now % 86400;
61 end
57 return true; 62 return true;
58 end 63 end
59 64
60 local function task_removed(event : task_event) : boolean 65 local function task_removed(event : task_event) : boolean
61 local task = event.item; 66 local task = event.item;