fixing Issue 57. Errorcode 12 is 'again'. Fail startup on again if not settings.insist

This commit is contained in:
Axel Kittenberger 2011-08-17 09:46:36 +00:00
parent dc1dd69c42
commit 09a0af3495
2 changed files with 26 additions and 12 deletions

View File

@ -91,7 +91,6 @@ l_addwatch(lua_State *L)
"'CloseWrite after Modify' not implemented."); "'CloseWrite after Modify' not implemented.");
exit(-1); // ERRNO exit(-1); // ERRNO
} else { } else {
/* will be done in future */
printlogf(L, "Error", printlogf(L, "Error",
"'%s' not a valid inotfiyMode.", imode); "'%s' not a valid inotfiyMode.", imode);
exit(-1); // ERRNO exit(-1); // ERRNO

View File

@ -2572,6 +2572,7 @@ USAGE:
OPTIONS: OPTIONS:
-delay SECS Overrides default delay times -delay SECS Overrides default delay times
-help Shows this -help Shows this
-inisit Continues startup even if it cannot connect
-log all Logs everything (debug) -log all Logs everything (debug)
-log scarce Logs errors only -log scarce Logs errors only
-log [Category] Turns on logging for a debug category -log [Category] Turns on logging for a debug category
@ -2622,6 +2623,10 @@ function runner.configure(args, monitors)
{1, function(secs) {1, function(secs)
clSettings.delay = secs clSettings.delay = secs
end}, end},
insist =
{0, function()
clSettings.insist = true
end},
log = log =
{1, nil}, {1, nil},
logfile = logfile =
@ -2643,7 +2648,7 @@ function runner.configure(args, monitors)
end}, end},
nodaemon = nodaemon =
{0, function() {0, function()
clSettings.nodaemon=true clSettings.nodaemon = true
end}, end},
pidfile = pidfile =
{1, function(file) {1, function(file)
@ -3063,7 +3068,7 @@ local rsync_exitcodes = {
[ 6] = "again", [ 6] = "again",
[ 10] = "again", [ 10] = "again",
[ 11] = "again", [ 11] = "again",
-- [ 12] = "again", -- dont, consistent failure, if e.g. target dir not there. [ 12] = "again",
[ 14] = "again", [ 14] = "again",
[ 20] = "again", [ 20] = "again",
[ 21] = "again", [ 21] = "again",
@ -3319,7 +3324,7 @@ local default_rsyncssh = {
local zPaths = table.concat(paths, "\000") local zPaths = table.concat(paths, "\000")
log("Normal", "Rsyncing list\n", sPaths) log("Normal", "Rsyncing list\n", sPaths)
spawn( spawn(
elist, rsyncBinary, elist, config.rsyncBinary,
"<", zPaths, "<", zPaths,
config.rsyncOpts, config.rsyncOpts,
"--from0", "--from0",
@ -3337,9 +3342,14 @@ local default_rsyncssh = {
if exitcode == 0 then if exitcode == 0 then
log("Normal", "Startup of '",agent.source,"' finished.") log("Normal", "Startup of '",agent.source,"' finished.")
elseif rsync_exitcodes[exitcode] == "again" then elseif rsync_exitcodes[exitcode] == "again" then
log("Normal", if settings.insist then
"Retrying startup of '",agent.source,"'.") log("Normal", "Retrying startup of '",agent.source,"'.")
return "again" return "again"
else
log("Error",
"Temporary or permanent failure on startup. Terminating since not insist'ing.");
terminate(-1) -- ERRNO
end
else else
log("Error", "Failure on startup of '",agent.source,"'.") log("Error", "Failure on startup of '",agent.source,"'.")
terminate(-1) -- ERRNO terminate(-1) -- ERRNO
@ -3388,7 +3398,7 @@ local default_rsyncssh = {
log("Normal", "recursive startup rsync: ", config.source, log("Normal", "recursive startup rsync: ", config.source,
" -> ", config.host .. ":" .. config.targetdir) " -> ", config.host .. ":" .. config.targetdir)
spawn( spawn(
event, rsyncBinary, event, config.rsyncBinary,
"--delete", "--delete",
"-r", "-r",
config.rsyncOpts, config.rsyncOpts,
@ -3400,7 +3410,7 @@ local default_rsyncssh = {
log("Normal", "recursive startup rsync: ", config.source, log("Normal", "recursive startup rsync: ", config.source,
" -> ", config.host .. ":" .. config.targetdir, " excluding\n") " -> ", config.host .. ":" .. config.targetdir, " excluding\n")
spawn( spawn(
event, rsyncBinary, event, config.rsyncBinary,
"<", exS, "<", exS,
"--exclude-from=-", "--exclude-from=-",
"--delete", "--delete",
@ -3533,9 +3543,14 @@ local default_direct = {
elseif rsync_exitcodes and elseif rsync_exitcodes and
rsync_exitcodes[exitcode] == "again" rsync_exitcodes[exitcode] == "again"
then then
log("Normal", if settings.insist then
"Retrying startup of '",agent.source,"'.") log("Normal", "Retrying startup of '",agent.source,"'.")
return "again" return "again"
else
log("Error",
"Temporary or permanent failure on startup. Terminating since not insist'ing.");
terminate(-1) -- ERRNO
end
else else
log("Error", "Failure on startup of '",agent.source,"'.") log("Error", "Failure on startup of '",agent.source,"'.")
terminate(-1) -- ERRNO terminate(-1) -- ERRNO