Software /
code /
prosody
Comparison
plugins/mod_cron.lua @ 12489:8b42575738f0 0.12
mod_cron: Fix recording last task run time #1751
The type checks, they do nothing!
Observed: Tasks that were supposed to run weekly or daily were running
each hour.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 05 May 2022 14:10:59 +0200 |
parent | 12186:7f25ac9d8f0d |
child | 12977:74b9e05af71e |
comparison
equal
deleted
inserted
replaced
12488:3183f358a88f | 12489:8b42575738f0 |
---|---|
43 local function should_run(when, last) return not last or last + periods[when] * 0.995 <= os.time() end | 43 local function should_run(when, last) return not last or last + periods[when] * 0.995 <= os.time() end |
44 | 44 |
45 local function run_task(task) | 45 local function run_task(task) |
46 local started_at = os.time(); | 46 local started_at = os.time(); |
47 task:run(started_at); | 47 task:run(started_at); |
48 task.last = started_at; | |
48 task:save(started_at); | 49 task:save(started_at); |
49 end | 50 end |
50 | 51 |
51 local task_runner = async.runner(run_task); | 52 local task_runner = async.runner(run_task); |
52 scheduled = module:add_timer(1, function() | 53 scheduled = module:add_timer(1, function() |