mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-04 10:58:28 +00:00
add onepass option to exit after initial sync
This commit is contained in:
parent
42413cabbe
commit
188b691bea
@ -120,7 +120,14 @@ default.collect = function
|
|||||||
agent.target,
|
agent.target,
|
||||||
' finished.'
|
' finished.'
|
||||||
)
|
)
|
||||||
|
if settings('onepass')
|
||||||
|
then
|
||||||
|
log(
|
||||||
|
'Normal',
|
||||||
|
'onepass config set, exiting'
|
||||||
|
)
|
||||||
|
terminate( 0 )
|
||||||
|
end
|
||||||
return 'ok'
|
return 'ok'
|
||||||
elseif rc == 'again'
|
elseif rc == 'again'
|
||||||
then
|
then
|
||||||
|
5
lsyncd.c
5
lsyncd.c
@ -91,6 +91,7 @@ struct settings settings = {
|
|||||||
.log_facility = LOG_USER,
|
.log_facility = LOG_USER,
|
||||||
.log_level = LOG_NOTICE,
|
.log_level = LOG_NOTICE,
|
||||||
.nodaemon = false,
|
.nodaemon = false,
|
||||||
|
.onepass = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1630,6 +1631,10 @@ l_configure( lua_State *L )
|
|||||||
{
|
{
|
||||||
settings.nodaemon = true;
|
settings.nodaemon = true;
|
||||||
}
|
}
|
||||||
|
else if( !strcmp( command, "onepass" ) )
|
||||||
|
{
|
||||||
|
settings.onepass = true;
|
||||||
|
}
|
||||||
else if( !strcmp( command, "logfile" ) )
|
else if( !strcmp( command, "logfile" ) )
|
||||||
{
|
{
|
||||||
const char * file = luaL_checkstring( L, 2 );
|
const char * file = luaL_checkstring( L, 2 );
|
||||||
|
1
lsyncd.h
1
lsyncd.h
@ -57,6 +57,7 @@ extern struct settings {
|
|||||||
int log_facility; // The syslog facility
|
int log_facility; // The syslog facility
|
||||||
int log_level; // -1 logs everything, 0 normal mode, LOG_ERROR errors only.
|
int log_level; // -1 logs everything, 0 normal mode, LOG_ERROR errors only.
|
||||||
bool nodaemon; // True if Lsyncd shall not daemonize.
|
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.
|
char * pidfile; // If not NULL Lsyncd writes its pid into this file.
|
||||||
|
|
||||||
} settings;
|
} settings;
|
||||||
|
16
lsyncd.lua
16
lsyncd.lua
@ -75,6 +75,7 @@ local settingsCheckgauge =
|
|||||||
logfile = true,
|
logfile = true,
|
||||||
pidfile = true,
|
pidfile = true,
|
||||||
nodaemon = true,
|
nodaemon = true,
|
||||||
|
onepass = true,
|
||||||
statusFile = true,
|
statusFile = true,
|
||||||
statusInterval = true,
|
statusInterval = true,
|
||||||
logfacility = true,
|
logfacility = true,
|
||||||
@ -4614,6 +4615,7 @@ OPTIONS:
|
|||||||
-log [Category] Turns on logging for a debug category
|
-log [Category] Turns on logging for a debug category
|
||||||
-logfile FILE Writes log to FILE (DEFAULT: uses syslog)
|
-logfile FILE Writes log to FILE (DEFAULT: uses syslog)
|
||||||
-nodaemon Does not detach and logs to stdout/stderr
|
-nodaemon Does not detach and logs to stdout/stderr
|
||||||
|
-onepass Sync once and exit
|
||||||
-pidfile FILE Writes Lsyncds PID into FILE
|
-pidfile FILE Writes Lsyncds PID into FILE
|
||||||
-runner FILE Loads Lsyncds lua part from FILE
|
-runner FILE Loads Lsyncds lua part from FILE
|
||||||
-version Prints versions and exits
|
-version Prints versions and exits
|
||||||
@ -4729,6 +4731,15 @@ function runner.configure( args, monitors )
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onepass =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
function
|
||||||
|
( )
|
||||||
|
clSettings.onepass = true
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
pidfile =
|
pidfile =
|
||||||
{
|
{
|
||||||
1,
|
1,
|
||||||
@ -4968,6 +4979,11 @@ function runner.initialize( firstTime )
|
|||||||
lsyncd.configure( 'nodaemon' )
|
lsyncd.configure( 'nodaemon' )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if uSettings.onepass
|
||||||
|
then
|
||||||
|
lsyncd.configure( 'onepass' )
|
||||||
|
end
|
||||||
|
|
||||||
if uSettings.logfile
|
if uSettings.logfile
|
||||||
then
|
then
|
||||||
lsyncd.configure( 'logfile', uSettings.logfile )
|
lsyncd.configure( 'logfile', uSettings.logfile )
|
||||||
|
Loading…
Reference in New Issue
Block a user