1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
function set_crons()
mcp.register_cron("foo",
{ every = 2, func = function()
foo_run = 1
end })
mcp.register_cron("reload",
{ every = 3, func = function()
if foo_run and once_run then
mcp.schedule_config_reload()
end
end })
-- will run once per reload.
mcp.register_cron("once",
{ every = 1, rerun = false, func = function()
once_run = 1
end })
end
function set_crons2()
mcp.register_cron("bar",
{ every = 2, func = function()
bar_run = 1
end })
mcp.register_cron("reload",
{ every = 3, func = function()
-- ensure the old crons didn't also run.
if bar_run and not foo_run and once_again and not once_run then
mcp.schedule_config_reload()
end
end })
-- will run once per reload.
mcp.register_cron("onceagain",
{ every = 3, rerun = false, func = function()
once_again = 1
end })
end
function mcp_config_pools()
if foo_run == nil then
set_crons()
else
foo_run = nil
once_run = nil
set_crons2()
end
end
function mcp_config_routes()
-- do nothing.
end
|