Merge remote-tracking branch 'origin/pr/541'

This commit is contained in:
Daniel Poelzleithner 2021-12-10 12:51:01 +01:00
commit d737c03c03
4 changed files with 30 additions and 1 deletions

View File

@ -120,7 +120,14 @@ default.collect = function
agent.target,
' finished.'
)
if settings('onepass')
then
log(
'Normal',
'onepass config set, exiting'
)
terminate( 0 )
end
return 'ok'
elseif rc == 'again'
then

View File

@ -91,6 +91,7 @@ struct settings settings = {
.log_facility = LOG_USER,
.log_level = LOG_NOTICE,
.nodaemon = false,
.onepass = false,
};
@ -1630,6 +1631,10 @@ 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 );

View File

@ -57,6 +57,7 @@ extern struct settings {
int log_facility; // The syslog facility
int log_level; // -1 logs everything, 0 normal mode, LOG_ERROR errors only.
bool nodaemon; // True if Lsyncd shall not daemonize.
bool onepass; // True if Lsyncd should exit after first sync pass
char * pidfile; // If not NULL Lsyncd writes its pid into this file.
} settings;

View File

@ -75,6 +75,7 @@ local settingsCheckgauge =
logfile = true,
pidfile = true,
nodaemon = true,
onepass = true,
statusFile = true,
statusInterval = true,
logfacility = true,
@ -4643,6 +4644,7 @@ OPTIONS:
-log [Category] Turns on logging for a debug category
-logfile FILE Writes log to FILE (DEFAULT: uses syslog)
-nodaemon Does not detach and logs to stdout/stderr
-onepass Sync once and exit
-pidfile FILE Writes Lsyncds PID into FILE
-runner FILE Loads Lsyncds lua part from FILE
-script FILE Script to load before execting runner (ADVANCED)
@ -4760,6 +4762,15 @@ function runner.configure( args, monitors )
end
},
onepass =
{
0,
function
( )
clSettings.onepass = true
end
},
pidfile =
{
1,
@ -5034,6 +5045,11 @@ 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 )