Improved timed behavior

This commit is contained in:
deajan 2016-11-30 12:55:48 +01:00
parent bf8cacd4b6
commit fd204349fb
2 changed files with 19 additions and 13 deletions

View File

@ -3,8 +3,8 @@
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1.5 PROGRAM_VERSION=1.1.6-beta
PROGRAM_BUILD=2016111701 PROGRAM_BUILD=2016113001
IS_STABLE=yes IS_STABLE=yes
source "./ofunctions.sh" source "./ofunctions.sh"
@ -28,7 +28,7 @@ function TrapStop {
} }
function TrapQuit { function TrapQuit {
local exitcode= local exitcode
# Get ERROR / WARN alert flags from subprocesses that call Logger # Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID" ]; then if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID" ]; then
@ -1652,7 +1652,6 @@ do
;; ;;
--initiator=*) --initiator=*)
_QUICK_SYNC=$(($_QUICK_SYNC + 1)) _QUICK_SYNC=$(($_QUICK_SYNC + 1))
no_maxtime=1
INITIATOR_SYNC_DIR=${i##*=} INITIATOR_SYNC_DIR=${i##*=}
opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\"" opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\""
;; ;;
@ -1660,7 +1659,6 @@ do
_QUICK_SYNC=$(($_QUICK_SYNC + 1)) _QUICK_SYNC=$(($_QUICK_SYNC + 1))
TARGET_SYNC_DIR=${i##*=} TARGET_SYNC_DIR=${i##*=}
opts=$opts" --target=\"$TARGET_SYNC_DIR\"" opts=$opts" --target=\"$TARGET_SYNC_DIR\""
no_maxtime=1
;; ;;
--rsakey=*) --rsakey=*)
SSH_RSA_PRIVATE_KEY=${i##*=} SSH_RSA_PRIVATE_KEY=${i##*=}
@ -1772,7 +1770,7 @@ opts="${opts# *}"
GetRemoteOS GetRemoteOS
InitRemoteOSSettings InitRemoteOSSettings
if [ $no_maxtime -eq 1 ]; then if [ $no_maxtime -eq 1 ] ; then
SOFT_MAX_EXEC_TIME=0 SOFT_MAX_EXEC_TIME=0
HARD_MAX_EXEC_TIME=0 HARD_MAX_EXEC_TIME=0
fi fi

View File

@ -1,4 +1,4 @@
## FUNC_BUILD=2016071902-g ## FUNC_BUILD=2016071902-h
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -38,14 +38,16 @@ fi #__WITH_PARANOIA_DEBUG
## allow debugging from command line with _DEBUG=yes ## allow debugging from command line with _DEBUG=yes
if [ ! "$_DEBUG" == "yes" ]; then if [ ! "$_DEBUG" == "yes" ]; then
_DEBUG=no _DEBUG=no
SLEEP_TIME=.1
_VERBOSE=0 _VERBOSE=0
else else
SLEEP_TIME=1
trap 'TrapError ${LINENO} $?' ERR trap 'TrapError ${LINENO} $?' ERR
_VERBOSE=1 _VERBOSE=1
fi fi
if [ "$SLEEP_TIME" == "" ]; then
SLEEP_TIME=.1
fi
SCRIPT_PID=$$ SCRIPT_PID=$$
LOCAL_USER=$(whoami) LOCAL_USER=$(whoami)
@ -764,10 +766,10 @@ function WaitForTaskCompletion {
KillChilds $pid KillChilds $pid
if [ $? == 0 ]; then if [ $? == 0 ]; then
Logger "Task stopped successfully" "NOTICE" Logger "Task stopped successfully" "NOTICE"
return 0
else else
return 1 Logger "Could not stop task" "ERROR"
fi fi
return 1
fi fi
fi fi
sleep $SLEEP_TIME sleep $SLEEP_TIME
@ -814,10 +816,16 @@ function WaitForCompletion {
KillChilds $pid KillChilds $pid
if [ $? == 0 ]; then if [ $? == 0 ]; then
Logger "Task stopped successfully" "NOTICE" Logger "Task stopped successfully" "NOTICE"
return 0
else else
return 1 Logger "Could not stop task" "ERROR"
fi fi
return 1
#if [ $? == 0 ]; then
# Logger "Task stopped successfully" "NOTICE"
# return 0
#else
# return 1
#fi
fi fi
fi fi
sleep $SLEEP_TIME sleep $SLEEP_TIME