Comparison

teal-src/plugins/mod_cron.tl @ 12186:7f25ac9d8f0d

mod_cron: Allow for a small amount of timer drift If the timer activates a bit early then a task might be just a few seconds short of being allowed to run. This would run such a task rather than wait another hour. The value 0.5% chosen so that a weekly task does not run an entire hour earlier than last time.
author Kim Alvefur <zash@zash.se>
date Sat, 15 Jan 2022 09:09:24 +0100
parent 12002:cbed7d8d8f35
child 12489:8b42575738f0
comparison
equal deleted inserted replaced
12185:708769a4c5da 12186:7f25ac9d8f0d
76 active_hosts[host_module.host]=nil; 76 active_hosts[host_module.host]=nil;
77 end 77 end
78 end 78 end
79 79
80 local function should_run(when : frequency, last : integer) : boolean 80 local function should_run(when : frequency, last : integer) : boolean
81 return not last or last + periods[when] <= os.time(); 81 return not last or last + periods[when]*0.995 <= os.time();
82 end 82 end
83 83
84 local function run_task(task : task_spec) 84 local function run_task(task : task_spec)
85 local started_at = os.time(); 85 local started_at = os.time();
86 task:run(started_at); 86 task:run(started_at);