File: proxycron.lua

package info (click to toggle)
memcached 1.6.39-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,320 kB
  • sloc: ansic: 62,281; perl: 12,500; sh: 4,569; makefile: 468; python: 402; xml: 59
file content (54 lines) | stat: -rw-r--r-- 1,271 bytes parent folder | download | duplicates (2)
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