mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-09 01:44:16 +00:00
reworked exitcodes
This commit is contained in:
parent
41f5d23459
commit
4de8c935c2
126
lsyncd.lua
126
lsyncd.lua
@ -3135,6 +3135,7 @@ end
|
|||||||
-- Exitcodes to retry on network failures of rsync.
|
-- Exitcodes to retry on network failures of rsync.
|
||||||
--
|
--
|
||||||
local rsync_exitcodes = {
|
local rsync_exitcodes = {
|
||||||
|
[ 0] = "ok",
|
||||||
[ 1] = "die",
|
[ 1] = "die",
|
||||||
[ 2] = "die",
|
[ 2] = "die",
|
||||||
[ 3] = "again",
|
[ 3] = "again",
|
||||||
@ -3148,6 +3149,8 @@ local rsync_exitcodes = {
|
|||||||
[ 20] = "again",
|
[ 20] = "again",
|
||||||
[ 21] = "again",
|
[ 21] = "again",
|
||||||
[ 22] = "again",
|
[ 22] = "again",
|
||||||
|
[ 23] = "ok", -- partial transfers are ok, since Lsyncd has registered the event that
|
||||||
|
[ 24] = "ok", -- caused the transfer to be partial and will recall rsync.
|
||||||
[ 25] = "die",
|
[ 25] = "die",
|
||||||
[ 30] = "again",
|
[ 30] = "again",
|
||||||
[ 35] = "again",
|
[ 35] = "again",
|
||||||
@ -3158,6 +3161,7 @@ local rsync_exitcodes = {
|
|||||||
-- Exitcodes to retry on network failures of rsync.
|
-- Exitcodes to retry on network failures of rsync.
|
||||||
--
|
--
|
||||||
local ssh_exitcodes = {
|
local ssh_exitcodes = {
|
||||||
|
[0] = "ok",
|
||||||
[255] = "again",
|
[255] = "again",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3414,46 +3418,56 @@ local default_rsyncssh = {
|
|||||||
--
|
--
|
||||||
collect = function(agent, exitcode)
|
collect = function(agent, exitcode)
|
||||||
if not agent.isList and agent.etype == "Init" then
|
if not agent.isList and agent.etype == "Init" then
|
||||||
if exitcode == 0 then
|
local rc = rsync_exitcodes[exitcode]
|
||||||
|
if rc == "ok" then
|
||||||
log("Normal", "Startup of '",agent.source,"' finished.")
|
log("Normal", "Startup of '",agent.source,"' finished.")
|
||||||
elseif rsync_exitcodes[exitcode] == "again" then
|
elseif rc == "again" then
|
||||||
if settings.insist then
|
if settings.insist then
|
||||||
log("Normal", "Retrying startup of '",agent.source,"'.")
|
log("Normal", "Retrying startup of '",agent.source,"'.")
|
||||||
return "again"
|
|
||||||
else
|
else
|
||||||
log("Error",
|
log("Error",
|
||||||
"Temporary or permanent failure on startup. Terminating since not insist'ing.");
|
"Temporary or permanent failure on startup. Terminating since not insisting.");
|
||||||
terminate(-1) -- ERRNO
|
terminate(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
else
|
elseif rc == "die" then
|
||||||
log("Error", "Failure on startup of '",agent.source,"'.")
|
log("Error", "Failure on startup of '",agent.source,"'.")
|
||||||
terminate(-1) -- ERRNO
|
else
|
||||||
|
log("Error", "Unknown exitcode '",exticode,"' with a list")
|
||||||
|
rc = "die"
|
||||||
end
|
end
|
||||||
|
return rc
|
||||||
end
|
end
|
||||||
|
|
||||||
if agent.isList then
|
if agent.isList then
|
||||||
local rc = rsync_exitcodes[exitcode]
|
local rc = rsync_exitcodes[exitcode]
|
||||||
if rc == "die" then
|
if rc == "ok" then
|
||||||
return rc
|
|
||||||
end
|
|
||||||
if rc == "again" then
|
|
||||||
log("Normal", "Retrying a list on exitcode = ",exitcode)
|
|
||||||
else
|
|
||||||
log("Normal", "Finished a list = ",exitcode)
|
log("Normal", "Finished a list = ",exitcode)
|
||||||
|
elseif rc == "again" then
|
||||||
|
log("Normal", "Retrying a list on exitcode = ",exitcode)
|
||||||
|
elseif rc == "die" then
|
||||||
|
log("Error", "Failure on list on exitcode = ",exitcode)
|
||||||
|
else
|
||||||
|
log("Error", "Unknown exitcode on list = ",exitcode)
|
||||||
|
rc = "die"
|
||||||
end
|
end
|
||||||
return rc
|
return rc
|
||||||
else
|
else
|
||||||
local rc = ssh_exitcodes[exitcode]
|
local rc = ssh_exitcodes[exitcode]
|
||||||
if rc == "die" then
|
if rc == "ok" then
|
||||||
return rc
|
|
||||||
end
|
|
||||||
if rc == "again" then
|
|
||||||
log("Normal", "Retrying ",agent.etype,
|
|
||||||
" on ",agent.sourcePath," = ",exitcode)
|
|
||||||
else
|
|
||||||
log("Normal", "Finished ",agent.etype,
|
log("Normal", "Finished ",agent.etype,
|
||||||
" on ",agent.sourcePath," = ",exitcode)
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
elseif rc == "again" then
|
||||||
|
log("Normal", "Retrying ",agent.etype,
|
||||||
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
elseif rc == "die" then
|
||||||
|
log("Normal", "Failure ",agent.etype,
|
||||||
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
else
|
||||||
|
log("Error", "Unknown exitcode ",agent.etype,
|
||||||
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
rc = "die"
|
||||||
end
|
end
|
||||||
|
return rc
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -3613,29 +3627,29 @@ local default_direct = {
|
|||||||
local config = agent.config
|
local config = agent.config
|
||||||
|
|
||||||
if not agent.isList and agent.etype == "Init" then
|
if not agent.isList and agent.etype == "Init" then
|
||||||
if exitcode == 0 then
|
local rc = rsync_exitcodes[exitcode]
|
||||||
|
if rc == "ok" then
|
||||||
log("Normal", "Startup of '",agent.source,"' finished.")
|
log("Normal", "Startup of '",agent.source,"' finished.")
|
||||||
elseif rsync_exitcodes and
|
elseif rc == "again" then
|
||||||
rsync_exitcodes[exitcode] == "again"
|
|
||||||
then
|
|
||||||
if settings.insist then
|
if settings.insist then
|
||||||
log("Normal", "Retrying startup of '",agent.source,"'.")
|
log("Normal", "Retrying startup of '",agent.source,"'.")
|
||||||
return "again"
|
|
||||||
else
|
else
|
||||||
log("Error",
|
log("Error",
|
||||||
"Temporary or permanent failure on startup. Terminating since not insist'ing.");
|
"Temporary or permanent failure on startup. Terminating since not insisting.");
|
||||||
terminate(-1) -- ERRNO
|
terminate(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
else
|
elseif rc == "die" then
|
||||||
log("Error", "Failure on startup of '",agent.source,"'.")
|
log("Error", "Failure on startup of '",agent.source,"'.")
|
||||||
terminate(-1) -- ERRNO
|
else
|
||||||
|
log("Error", "Unknown exitcode '",exticode,"' with a list")
|
||||||
|
rc = "die"
|
||||||
end
|
end
|
||||||
return
|
return rc
|
||||||
end
|
end
|
||||||
|
|
||||||
-- everything else just is as is,
|
-- everything else is just as it is,
|
||||||
-- there is no network to retry something.
|
-- there is no network to retry something.
|
||||||
return nil
|
return
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -3709,45 +3723,61 @@ default = {
|
|||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
-- Default collector.
|
||||||
-- Called when collecting a finished child process
|
-- Called when collecting a finished child process
|
||||||
--
|
--
|
||||||
collect = function(agent, exitcode)
|
collect = function(agent, exitcode)
|
||||||
local config = agent.config
|
local config = agent.config
|
||||||
|
local rc
|
||||||
|
if config.exitcodes then
|
||||||
|
rc = config.exitcodes[exitcode]
|
||||||
|
elseif exitcode == 0 then
|
||||||
|
rc = "ok"
|
||||||
|
else
|
||||||
|
rc = "die"
|
||||||
|
end
|
||||||
|
|
||||||
if not agent.isList and agent.etype == "Init" then
|
if not agent.isList and agent.etype == "Init" then
|
||||||
if exitcode == 0 then
|
if rc == "ok" then
|
||||||
log("Normal", "Startup of '",agent.source,"' finished.")
|
log("Normal", "Startup of '",agent.source,"' finished.")
|
||||||
elseif config.exitcodes and
|
return "ok"
|
||||||
config.exitcodes[exitcode] == "again"
|
elseif rc == "again" then
|
||||||
then
|
log("Normal", "Retrying startup of '",agent.source,"'.")
|
||||||
log("Normal",
|
|
||||||
"Retrying startup of '",agent.source,"'.")
|
|
||||||
return "again"
|
return "again"
|
||||||
else
|
elseif rc == "die" then
|
||||||
log("Error", "Failure on startup of '",agent.source,"'.")
|
log("Error", "Failure on startup of '",agent.source,"'.")
|
||||||
terminate(-1) -- ERRNO
|
terminate(-1) -- ERRNO
|
||||||
|
else
|
||||||
|
log("Error", "Unknown exitcode '",exitcode,"' on startup of '",agent.source,"'.")
|
||||||
|
return "die"
|
||||||
end
|
end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local rc = config.exitcodes and config.exitcodes[exitcode]
|
|
||||||
if rc == "die" then
|
|
||||||
return rc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if agent.isList then
|
if agent.isList then
|
||||||
if rc == "again" then
|
if rc == "ok" then
|
||||||
log("Normal", "Retrying a list on exitcode = ",exitcode)
|
|
||||||
else
|
|
||||||
log("Normal", "Finished a list = ",exitcode)
|
log("Normal", "Finished a list = ",exitcode)
|
||||||
|
elseif rc == "again" then
|
||||||
|
log("Normal", "Retrying a list on exitcode = ",exitcode)
|
||||||
|
elseif rc == "die" then
|
||||||
|
log("Error", "Failure with a list on exitcode = ",exitcode)
|
||||||
|
else
|
||||||
|
log("Error", "Unknown exitcode '",exitcode,"' with a list")
|
||||||
|
rc = "die"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if rc == "again" then
|
if rc == "ok" then
|
||||||
log("Normal", "Retrying ",agent.etype,
|
log("Normal", "Retrying ",agent.etype,
|
||||||
" on ",agent.sourcePath," = ",exitcode)
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
else
|
elseif rc == "again" then
|
||||||
log("Normal", "Finished ",agent.etype,
|
log("Normal", "Finished ",agent.etype,
|
||||||
" on ",agent.sourcePath," = ",exitcode)
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
elseif rc == "die" then
|
||||||
|
log("Error", "Failure with ",agent.etype,
|
||||||
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
else
|
||||||
|
log("Normal", "Unknown exitcode '",exitcode,"' with ", agent.etype,
|
||||||
|
" on ",agent.sourcePath," = ",exitcode)
|
||||||
|
rc = "die"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return rc
|
return rc
|
||||||
|
Loading…
Reference in New Issue
Block a user