Comparison

plugins/mod_cron.lua @ 12009:f6fff0658108

mod_cron: Expose the One Timer via module environment This makes it easier to reschedule or otherwise manipulate the timer from e.g. the shell, which is handy for debugging.
author Kim Alvefur <zash@zash.se>
date Sat, 04 Dec 2021 17:46:37 +0100
parent 12002:cbed7d8d8f35
child 12186:7f25ac9d8f0d
comparison
equal deleted inserted replaced
12008:c01532ae6a3b 12009:f6fff0658108
47 task:run(started_at); 47 task:run(started_at);
48 task:save(started_at); 48 task:save(started_at);
49 end 49 end
50 50
51 local task_runner = async.runner(run_task); 51 local task_runner = async.runner(run_task);
52 module:add_timer(1, function() 52 scheduled = module:add_timer(1, function()
53 module:log("info", "Running periodic tasks"); 53 module:log("info", "Running periodic tasks");
54 local delay = 3600; 54 local delay = 3600;
55 for host in pairs(active_hosts) do 55 for host in pairs(active_hosts) do
56 module:log("debug", "Running periodic tasks for host %s", host); 56 module:log("debug", "Running periodic tasks for host %s", host);
57 for _, task in ipairs(module:context(host):get_host_items("task")) do 57 for _, task in ipairs(module:context(host):get_host_items("task")) do