mirror of https://github.com/octoleo/lsyncd.git
This commit is contained in:
parent
1a2b48871c
commit
3df30b2125
|
@ -6,18 +6,18 @@
|
||||||
settings = {
|
settings = {
|
||||||
-- logfile = "/tmp/lsyncd",
|
-- logfile = "/tmp/lsyncd",
|
||||||
-- nodaemon = true,
|
-- nodaemon = true,
|
||||||
statusfile = "/tmp/lsyncd.stat",
|
statusFile = "/tmp/lsyncd.stat",
|
||||||
statusintervall = 0,
|
statusIntervall = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
----
|
----
|
||||||
-- for testing purposes. uses bash command to hold local dirs in sync.
|
-- for testing purposes. uses bash command to hold local dirs in sync.
|
||||||
--
|
--
|
||||||
prefix = "sleep 1 && "
|
prefix = "sleep 5 && "
|
||||||
slowbash = {
|
slowbash = {
|
||||||
delay = 5,
|
delay = 5,
|
||||||
|
|
||||||
maxProcesses = 5,
|
maxProcesses = 3,
|
||||||
|
|
||||||
onStartup = function(event)
|
onStartup = function(event)
|
||||||
log("Normal", "cp -r from ", event.source, " -> ", event.target)
|
log("Normal", "cp -r from ", event.source, " -> ", event.target)
|
||||||
|
|
52
lsyncd.lua
52
lsyncd.lua
|
@ -532,12 +532,22 @@ local Sync = (function()
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
error("Did not find a delay to be removed!")
|
error("Did not find a delay to be removed!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- free all delays blocked by this one.
|
||||||
|
if delay.blocks then
|
||||||
|
for i, vd in pairs(delay.blocks) do
|
||||||
|
if vd.status ~= "block" then
|
||||||
|
error("unblocking an non-blocked event!")
|
||||||
|
end
|
||||||
|
vd.status = "wait"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Collects a child process
|
-- Collects a child process
|
||||||
--
|
--
|
||||||
|
@ -555,15 +565,6 @@ local Sync = (function()
|
||||||
local rc = self.config.collect(InletControl.d2e(delay), exitcode)
|
local rc = self.config.collect(InletControl.d2e(delay), exitcode)
|
||||||
-- TODO honor return codes of the collect
|
-- TODO honor return codes of the collect
|
||||||
|
|
||||||
-- set all delays blocked by this on wait.
|
|
||||||
if delay.blocks then
|
|
||||||
for i, vd in pairs(delay.blocks) do
|
|
||||||
if vd.status ~= "block" then
|
|
||||||
error("unblocking an non-blocked event!")
|
|
||||||
end
|
|
||||||
vd.status = "wait"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
removeDelay(self, delay)
|
removeDelay(self, delay)
|
||||||
log("Delay","Finish of ",delay.etype," on ",
|
log("Delay","Finish of ",delay.etype," on ",
|
||||||
self.source,delay.path," = ",exitcode)
|
self.source,delay.path," = ",exitcode)
|
||||||
|
@ -667,7 +668,8 @@ local Sync = (function()
|
||||||
log("Delay", "Stacking ",nd.etype," upon ",
|
log("Delay", "Stacking ",nd.etype," upon ",
|
||||||
od.etype," on ",path)
|
od.etype," on ",path)
|
||||||
stack(od, nd)
|
stack(od, nd)
|
||||||
break
|
table.insert(self.delays, nd)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- loops over all oe, oe2, ne, ne2 combos.
|
-- loops over all oe, oe2, ne, ne2 combos.
|
||||||
|
@ -679,13 +681,13 @@ local Sync = (function()
|
||||||
-- start with first oe
|
-- start with first oe
|
||||||
nel = ne2
|
nel = ne2
|
||||||
oel = oe
|
oel = oe
|
||||||
|
else
|
||||||
|
oel = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
il = il - 1
|
il = il - 1
|
||||||
end
|
end
|
||||||
if il <= 0 then
|
log("Delay", "Registering ",nd.etype," on ",path)
|
||||||
log("Delay", "Registering ",nd.etype," on ",path)
|
|
||||||
end
|
|
||||||
-- there was no hit on collapse or it decided to stack.
|
-- there was no hit on collapse or it decided to stack.
|
||||||
table.insert(self.delays, nd)
|
table.insert(self.delays, nd)
|
||||||
end
|
end
|
||||||
|
@ -771,14 +773,15 @@ local Sync = (function()
|
||||||
f:write(self.config.name," source=",self.source,"\n")
|
f:write(self.config.name," source=",self.source,"\n")
|
||||||
f:write("There are ",#self.delays, " delays\n")
|
f:write("There are ",#self.delays, " delays\n")
|
||||||
for i, vd in ipairs(self.delays) do
|
for i, vd in ipairs(self.delays) do
|
||||||
local s = vd.status
|
local st = vd.status
|
||||||
f:write(string.sub(spaces, 1, 5 - #vd.status))
|
f:write(st, string.sub(spaces, 1, 7 - #st))
|
||||||
f:write(" ",vd.etype)
|
f:write(vd.etype," ")
|
||||||
-- TODO spaces
|
-- TODO spaces
|
||||||
f:write(vd.path)
|
f:write(vd.path)
|
||||||
if (vd.path2) then
|
if (vd.path2) then
|
||||||
f:write(" -> ",vd.path2)
|
f:write(" -> ",vd.path2)
|
||||||
end
|
end
|
||||||
|
f:write("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1131,11 +1134,11 @@ local StatusFile = (function()
|
||||||
local lastWritten = false
|
local lastWritten = false
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Timestamp when a statusfile should be written
|
-- Timestamp when a status file should be written
|
||||||
local alarm = false
|
local alarm = false
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Returns when the statusfile should be written
|
-- Returns when the status file should be written
|
||||||
--
|
--
|
||||||
local function getAlarm()
|
local function getAlarm()
|
||||||
return alarm
|
return alarm
|
||||||
|
@ -1169,9 +1172,9 @@ local StatusFile = (function()
|
||||||
end
|
end
|
||||||
|
|
||||||
log("Statusfile", "writing now")
|
log("Statusfile", "writing now")
|
||||||
local f, err = io.open(settings.statusfile, "w")
|
local f, err = io.open(settings.statusFile, "w")
|
||||||
if not f then
|
if not f then
|
||||||
log("Error", "Cannot open statusfile '"..settings.statusfile..
|
log("Error", "Cannot open status file '"..settings.statusFile..
|
||||||
"' :"..err)
|
"' :"..err)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1254,7 +1257,7 @@ function runner.cycle(now)
|
||||||
s:invokeActions(now)
|
s:invokeActions(now)
|
||||||
end
|
end
|
||||||
|
|
||||||
if settings.statusfile then
|
if settings.statusFile then
|
||||||
StatusFile.write(now)
|
StatusFile.write(now)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1546,6 +1549,11 @@ default = {
|
||||||
if func then
|
if func then
|
||||||
func(event, event2)
|
func(event, event2)
|
||||||
end
|
end
|
||||||
|
-- if function didnt change the wait status its not interested
|
||||||
|
-- in this event -> drop it.
|
||||||
|
if event.status == "wait" then
|
||||||
|
inlet.cancelEvent(event)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
Loading…
Reference in New Issue