plugins/mod_cron.lua
changeset 12190 7f25ac9d8f0d
parent 12013 f6fff0658108
child 12493 8b42575738f0
equal deleted inserted replaced
12189:708769a4c5da 12190:7f25ac9d8f0d
    38 	host_module:handle_items("task", task_added, task_removed, true);
    38 	host_module:handle_items("task", task_added, task_removed, true);
    39 
    39 
    40 	function host_module.unload() active_hosts[host_module.host] = nil; end
    40 	function host_module.unload() active_hosts[host_module.host] = nil; end
    41 end
    41 end
    42 
    42 
    43 local function should_run(when, last) return not last or last + periods[when] <= 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:save(started_at);
    48 	task:save(started_at);