mirror of https://github.com/octoleo/lsyncd.git
imply --insist on reset
This commit is contained in:
parent
eb6df1bed4
commit
c7d11e4eef
20
lsyncd.c
20
lsyncd.c
|
@ -128,12 +128,15 @@ struct settings settings = {
|
||||||
static bool is_daemon = false;
|
static bool is_daemon = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True after first configuration phase. This is to write configuration error
|
* False after first time Lsyncd started up.
|
||||||
* messages to stdout/stderr after being first started. Then it uses whatever
|
*
|
||||||
* it has been configured to. This survives a reset by HUP signal or
|
* Thus configuration error messages are written to stdout/stderr only on
|
||||||
* inotify OVERFLOW.
|
* first start.
|
||||||
|
*
|
||||||
|
* All other resets (HUP or inotify OVERFLOW) run with implictly --insist
|
||||||
|
* turned on and thus Lsyncd not failing on a not responding target.
|
||||||
*/
|
*/
|
||||||
static bool running = false;
|
static bool first_time = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to TERM or HUP in signal handler, when lsyncd should end or reset ASAP.
|
* Set to TERM or HUP in signal handler, when lsyncd should end or reset ASAP.
|
||||||
|
@ -288,7 +291,7 @@ logstring0(int priority, const char *cat, const char *message)
|
||||||
if (priority < 0) {
|
if (priority < 0) {
|
||||||
priority = LOG_DEBUG;
|
priority = LOG_DEBUG;
|
||||||
}
|
}
|
||||||
if (!running) {
|
if (first_time) {
|
||||||
/* lsyncd is in intial configuration.
|
/* lsyncd is in intial configuration.
|
||||||
* thus just print to normal stdout/stderr. */
|
* thus just print to normal stdout/stderr. */
|
||||||
if (priority >= LOG_ERR) {
|
if (priority >= LOG_ERR) {
|
||||||
|
@ -1166,7 +1169,7 @@ l_configure(lua_State *L)
|
||||||
/* set by runner after first initialize
|
/* set by runner after first initialize
|
||||||
* from this on log to configurated log end instead of
|
* from this on log to configurated log end instead of
|
||||||
* stdout/stderr */
|
* stdout/stderr */
|
||||||
running = true;
|
first_time = false;
|
||||||
if (settings.log_syslog || !settings.log_file) {
|
if (settings.log_syslog || !settings.log_file) {
|
||||||
openlog(settings.log_ident ? settings.log_ident : "lsyncd",
|
openlog(settings.log_ident ? settings.log_ident : "lsyncd",
|
||||||
0,
|
0,
|
||||||
|
@ -1992,7 +1995,8 @@ main1(int argc, char *argv[])
|
||||||
/* runs initialitions from runner
|
/* runs initialitions from runner
|
||||||
* lua code will set configuration and add watches */
|
* lua code will set configuration and add watches */
|
||||||
load_runner_func(L, "initialize");
|
load_runner_func(L, "initialize");
|
||||||
if (lua_pcall(L, 0, 0, -2)) {
|
lua_pushboolean(L, first_time);
|
||||||
|
if (lua_pcall(L, 1, 0, -3)) {
|
||||||
exit(-1); // ERRNO
|
exit(-1); // ERRNO
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
12
lsyncd.lua
12
lsyncd.lua
|
@ -2800,8 +2800,11 @@ end
|
||||||
|
|
||||||
----
|
----
|
||||||
-- Called from core on init or restart after user configuration.
|
-- Called from core on init or restart after user configuration.
|
||||||
|
--
|
||||||
|
-- @firstTime true the first time Lsyncd startup, false on resets
|
||||||
|
-- due to HUP signal or monitor queue OVERFLOW.
|
||||||
--
|
--
|
||||||
function runner.initialize()
|
function runner.initialize(firstTime)
|
||||||
-- creates settings if user didnt
|
-- creates settings if user didnt
|
||||||
settings = settings or {}
|
settings = settings or {}
|
||||||
|
|
||||||
|
@ -2816,13 +2819,18 @@ function runner.initialize()
|
||||||
end
|
end
|
||||||
settings[v]=true
|
settings[v]=true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- all command line settings overwrite config file settings
|
-- all command line settings overwrite config file settings
|
||||||
for k, v in pairs(clSettings) do
|
for k, v in pairs(clSettings) do
|
||||||
if k ~= "syncs" then
|
if k ~= "syncs" then
|
||||||
settings[k]=v
|
settings[k]=v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- implicitly force insist to be true on Lsyncd resets.
|
||||||
|
if not firstTime then
|
||||||
|
settings.insist = true
|
||||||
|
end
|
||||||
|
|
||||||
-- adds syncs specified by command line.
|
-- adds syncs specified by command line.
|
||||||
if clSettings.syncs then
|
if clSettings.syncs then
|
||||||
|
|
Loading…
Reference in New Issue