From de21ec41fadc97dbccc6ee6316eb1d6c8f4fd62f Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Tue, 19 Oct 2010 20:21:38 +0000 Subject: [PATCH] --- lsyncd-conf.lua | 8 ++++++++ lsyncd.lua | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lsyncd-conf.lua b/lsyncd-conf.lua index bfe443e..ef075f8 100644 --- a/lsyncd-conf.lua +++ b/lsyncd-conf.lua @@ -11,4 +11,12 @@ settings = { add("s", "d") -- add("s/s1", "t") +---- +-- Called for every source .. target pair on startup +-- Returns the pid of a spawned process +-- Return 0 if you dont exec something. +function startup_action(source, target) + print("startup recursive rsync: " .. source .. " -> " .. target) + return exec("/usr/bin/rsync", "-ltrs", source, target) +end diff --git a/lsyncd.lua b/lsyncd.lua index e2a4e1d..b72b022 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -159,9 +159,7 @@ function default_startup() print("--- startup ---") local pids = { } for i, o in ipairs(origins) do - print("startup recursive rsync: " .. o.source .. " -> " .. o.targetpath) - -- TODO userchangeablefunction - pid = lsyncd.exec("/usr/bin/rsync", "-ltrs", o.source, o.targetpath) + startup_action(o.source, o.targetpath) table.insert(pids, pid) end lsyncd.wait_pids(pids, "startup_collector") @@ -169,6 +167,7 @@ function default_startup() end startup = default_startup + ----- -- Called by the core for every child process that -- finished in startup phase