mirror of https://github.com/octoleo/lsyncd.git
Finish -onepass option to exit when all syncs ran sucessfully once
This commit is contained in:
parent
d737c03c03
commit
39f2f3a373
5
lsyncd.c
5
lsyncd.c
|
@ -91,7 +91,6 @@ struct settings settings = {
|
|||
.log_facility = LOG_USER,
|
||||
.log_level = LOG_NOTICE,
|
||||
.nodaemon = false,
|
||||
.onepass = false,
|
||||
};
|
||||
|
||||
|
||||
|
@ -1631,10 +1630,6 @@ l_configure( lua_State *L )
|
|||
{
|
||||
settings.nodaemon = true;
|
||||
}
|
||||
else if( !strcmp( command, "onepass" ) )
|
||||
{
|
||||
settings.onepass = true;
|
||||
}
|
||||
else if( !strcmp( command, "logfile" ) )
|
||||
{
|
||||
const char * file = luaL_checkstring( L, 2 );
|
||||
|
|
32
lsyncd.lua
32
lsyncd.lua
|
@ -2401,6 +2401,9 @@ local Sync = ( function
|
|||
' = ',
|
||||
exitcode
|
||||
)
|
||||
-- sets the initDone after the first success
|
||||
self.initDone = true
|
||||
|
||||
else
|
||||
-- sets the delay on wait again
|
||||
local alarm = self.config.delay
|
||||
|
@ -2804,6 +2807,10 @@ local Sync = ( function
|
|||
timestamp,
|
||||
' )'
|
||||
)
|
||||
if self.disabled
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
if self.processes:size( ) >= self.config.maxProcesses
|
||||
then
|
||||
|
@ -2992,6 +2999,8 @@ local Sync = ( function
|
|||
processes = CountArray.new( ),
|
||||
excludes = Excludes.new( ),
|
||||
filters = nil,
|
||||
initDone = false,
|
||||
disabled = false,
|
||||
|
||||
-- functions
|
||||
addBlanketDelay = addBlanketDelay,
|
||||
|
@ -4576,6 +4585,24 @@ function runner.cycle(
|
|||
error( 'runner.cycle() called while not running!' )
|
||||
end
|
||||
|
||||
if uSettings.onepass
|
||||
then
|
||||
local allDone = true
|
||||
for i, s in Syncs.iwalk( )
|
||||
do
|
||||
if s.initDone == true
|
||||
then
|
||||
s.disabled = true
|
||||
else
|
||||
allDone = false
|
||||
end
|
||||
end
|
||||
if allDone and processCount == 0 then
|
||||
log( 'Info', 'onepass active and all syncs finished. Exiting successfully')
|
||||
os.exit(0)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- goes through all syncs and spawns more actions
|
||||
-- if possibly. But only let Syncs invoke actions if
|
||||
|
@ -5045,11 +5072,6 @@ function runner.initialize( firstTime )
|
|||
lsyncd.configure( 'nodaemon' )
|
||||
end
|
||||
|
||||
if uSettings.onepass
|
||||
then
|
||||
lsyncd.configure( 'onepass' )
|
||||
end
|
||||
|
||||
if uSettings.logfile
|
||||
then
|
||||
lsyncd.configure( 'logfile', uSettings.logfile )
|
||||
|
|
Loading…
Reference in New Issue