davideuler / lsyncd

Automatically exported from code.google.com/p/lsyncd
GNU General Public License v2.0
0 stars 0 forks source link

lsyncd on arm system not finding getConfig() #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
upon starting lsyncd I get the following error:

[admin@NASC123B8 csync2]# lsyncd -nodaemon -log all /opt/etc/lsyncd.conf 
kernels clocks_per_sec=100
Call: configure()
Inotify: inotify fd = 3
Call: initialize()
11:26:42 Function: Inotify.addWatch(/share/MD0_DATA/exports/nginx/, (true), 
(nil), (nil))
11:26:42 Inotify: addwatch(/share/MD0_DATA/exports/nginx/)->1
11:26:42 Function: 
Inotify.addWatch(/share/MD0_DATA/exports/nginx/sites-available/, (true), (nil), 
(nil))
11:26:42 Inotify: addwatch(/share/MD0_DATA/exports/nginx/sites-available/)->2
11:26:42 Function: 
Inotify.addWatch(/share/MD0_DATA/exports/nginx/sites-enabled/, (true), (nil), 
(nil))
11:26:42 Inotify: addwatch(/share/MD0_DATA/exports/nginx/sites-enabled/)->3
11:26:42 Function: Inotify.addWatch(/share/MD0_DATA/exports/nginx/conf.d/, 
(true), (nil), (nil))
11:26:42 Inotify: addwatch(/share/MD0_DATA/exports/nginx/conf.d/)->4
11:26:42 Call: getAlarm()
11:26:42 Alarm: runner.getAlarm returns: (true)
11:26:42 Masterloop: immediately handling delays.
11:26:42 Call: cycle()
11:26:42 Function: invokeActions('Sync1',(Timestamp: 5273886.7))
11:26:42 Error: IN LUA: /opt/etc/lsyncd.conf:70: event does not have field 
'getConfig'
11:26:42 Error: Backtrace 1 :[C]:-1
11:26:42 Error: Backtrace 2 :lsyncd.lua:737
11:26:42 Error: Backtrace 3 :/opt/etc/lsyncd.conf:70
11:26:42 Error: Backtrace 4 :lsyncd.lua:1475
11:26:42 Error: Backtrace 5 :lsyncd.lua:2597

[admin@NASC123B8 csync2]# lsyncd -version
Version: 2.0.5

[admin@NASC123B8 csync2]# lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio

[admin@NASC123B8 csync2]# uname -a
Linux NASC123B8 2.6.33.2 #1 Fri May 20 07:16:37 CST 2011 armv5tel GNU/Linux

settings = {
        logident        = "lsyncd",
        logfacility     = "user",
        logfile         = "/opt/var/log/lsyncd/lsyncd.log",
        statusFile      = "/opt/var/log/lsyncd/status.log",
        statusInterval  = 1
}

initSync = {
    delay = 1,
    maxProcesses = 1,
    action = function(inlet)
        local config = inlet.getConfig()
        local elist = inlet.getEvents(function(event)
            return event.etype ~= "Blanket"
        end)
        local directory = string.sub(config.source, 1, -2)
        local paths = elist.getPaths(function(etype, path)
            return "\t" .. config.syncid .. ":" .. directory .. path
        end)
        log("Normal", "Processing syncing list:\n", table.concat(paths, "\n"))
        spawn(elist, "/opt/usr/sbin/csync2", "-C", config.syncid, "-x")
    end,
    collect = function(agent, exitcode)
        local config = agent.config
        if not agent.isList and agent.etype == "Blanket" then
            if exitcode == 0 then
                log("Normal", "Startup of '", config.syncid, "' instance finished.")
            elseif config.exitcodes and config.exitcodes[exitcode] == "again" then
                log("Normal", "Retrying startup of '", config.syncid, "' instance.")
                return "again"
            else
                log("Error", "Failure on startup of '", config.syncid, "' instance.")
                terminate(-1)
            end
            return
        end
        local rc = config.exitcodes and config.exitcodes[exitcode]
        if rc == "die" then
            return rc
        end
        if agent.isList then
            if rc == "again" then
                log("Normal", "Retrying events list on exitcode = ", exitcode)
            else
                log("Normal", "Finished events list = ", exitcode)
            end
        else
            if rc == "again" then
                log("Normal", "Retrying ", agent.etype, " on ", agent.sourcePath, " = ", exitcode)
            else
                log("Normal", "Finished ", agent.etype, " on ", agent.sourcePath, " = ", exitcode)
            end
        end
        return rc
    end,
    init = function(inlet)
        local config = inlet.getConfig()
        local event = inlet.createBlanketEvent()
        log("Normal", "Recursive startup sync: ", config.syncid, ":", config.source)
        spawn(event, "/opt/usr/sbin/csync2", "-C", config.syncid, "-x")
    end,
    prepare = function(config)
        if not config.syncid then
            error("Missing 'syncid' parameter.", 4)
        end
        local c = "csync2_" .. config.syncid .. ".cfg"
        local f, err = io.open("/opt/etc/csync2/" .. c, "r")
        if not f then
            error("Invalid 'syncid' parameter: " .. err, 4)
        end
        f:close()
    end
}

local sources = {
    ["/share/MD0_DATA/exports/nginx"] = "bps1and2"
}
for key, value in pairs(sources) do
    sync {initSync, source=key, syncid=value}
end

Original issue reported on code.google.com by t00_m4d_f00@web.de on 12 Oct 2011 at 9:28

GoogleCodeExporter commented 9 years ago
As just answered on the list. This script is for Lsyncd 2.0.0-2.0.4 and doesn't 
fit Lsyncd 2.0.5

Again Sorry for the iface change, but the error you see is because init() now 
receives an event and not an inlet, thats why getConfig() fails on the event:

Change 1: the 'init' function no longer receives an inlet and has to
create a "Blanket" event. It know receives an "Init" event right away.

So instead of old:
>        init = function(inlet)
>                local config = inlet.getConfig()
>                local event = inlet.createBlanketEvent()
>                log("Normal", "Recursive startup sync: ",
> config.syncid, ":", config.source)
>                spawn(event, "/usr/sbin/csync2", "-C", config.syncid,
> "-x")
>        end,

It should now be:

>        init = function(event)
>                local inlet = event.inlet;
>                local config = inlet.getConfig();
>                log("Normal", "Recursive startup sync: ",
> config.syncid, ":", config.source)
>                spawn(event, "/usr/sbin/csync2", "-C", config.syncid,
> "-x")
>        end,

Also "Blanket" events are no longer used for Startup, or even by
default at all. The Startup event is now called "Init"

So instead of
>                if not agent.isList and agent.etype == "Blanket" then

do

>                if not agent.isList and agent.etype == "Init" then

Similar
>                local elist = inlet.getEvents(function(event)
>                        return event.etype ~= "Blanket"
>                end)

becomes

>                local elist = inlet.getEvents(function(event)
>                        return event.etype ~= "Blanket"
>                end)

Original comment by axk...@gmail.com on 12 Oct 2011 at 9:34

GoogleCodeExporter commented 9 years ago

Original comment by axk...@gmail.com on 1 Nov 2011 at 10:17