Added MAX_WAIT support for MacOS daemon mode
This commit is contained in:
parent
070d7b7e3a
commit
85466e0ab0
|
@ -2052,6 +2052,8 @@ function SyncOnChanges {
|
|||
local cmd
|
||||
local retval
|
||||
|
||||
local sleepTime
|
||||
|
||||
if [ "$LOCAL_OS" == "MacOSX" ]; then
|
||||
if ! type fswatch > /dev/null 2>&1 ; then
|
||||
Logger "No inotifywait command found. Cannot monitor changes." "CRITICAL"
|
||||
|
@ -2086,8 +2088,12 @@ function SyncOnChanges {
|
|||
else
|
||||
inotifywait --exclude $OSYNC_DIR $RSYNC_PATTERNS $RSYNC_PARTIAL_EXCLUDE -qq -r -e create -e modify -e delete -e move -e attrib --timeout "$MAX_WAIT" "$INITIATOR_SYNC_DIR" &
|
||||
fi
|
||||
wait $!
|
||||
#wait $!
|
||||
sleepTime=SLEEP_TIME
|
||||
SLEEP_TIME=1
|
||||
WaitForTaskCompletion $! 0 $MAX_WAIT ${FUNCNAME[0]} true 0 true
|
||||
retval=$?
|
||||
SLEEP_TIME=$sleepTime
|
||||
if [ $retval == 0 ]; then
|
||||
Logger "#### Changes detected, waiting $MIN_WAIT seconds before running next sync." "NOTICE"
|
||||
sleep $MIN_WAIT
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
## FUNC_BUILD=2016112103
|
||||
## FUNC_BUILD=2016112104
|
||||
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||
|
||||
## To use in a program, define the following variables:
|
||||
|
@ -578,9 +578,10 @@ function WaitForTaskCompletion {
|
|||
local callerName="${4}" # Who called this function
|
||||
local counting="${5:-true}" # Count time since function has been launched if true, since script has been launched if false
|
||||
local keepLogging="${6:-0}" # Log a standby message every X seconds. Set to zero to disable logging
|
||||
local noError="${7:-false}" # When set to true, reaching soft or hard max time does not trigger an error
|
||||
|
||||
Logger "${FUNCNAME[0]} called by [$callerName]." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
||||
__CheckArguments 6 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
__CheckArguments 6-7 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
local soft_alert=false # Does a soft alert need to be triggered, if yes, send an alert once
|
||||
local log_ttime=0 # local time instance for comparaison
|
||||
|
@ -625,14 +626,16 @@ function WaitForTaskCompletion {
|
|||
fi
|
||||
|
||||
if [ $exec_time -gt $softMaxTime ]; then
|
||||
if [ $soft_alert == true ] && [ $softMaxTime -ne 0 ]; then
|
||||
if [ $soft_alert == true ] && [ $softMaxTime -ne 0 ] && [ $noError != true ]; then
|
||||
Logger "Max soft execution time exceeded for task [$callerName] with pids [$(joinString , ${pidsArray[@]})]." "WARN"
|
||||
soft_alert=true
|
||||
SendAlert true
|
||||
|
||||
fi
|
||||
if [ $exec_time -gt $hardMaxTime ] && [ $hardMaxTime -ne 0 ]; then
|
||||
if [ $noError != true ]; then
|
||||
Logger "Max hard execution time exceeded for task [$callerName] with pids [$(joinString , ${pidsArray[@]})]. Stopping task execution." "ERROR"
|
||||
fi
|
||||
for pid in "${pidsArray[@]}"; do
|
||||
KillChilds $pid true
|
||||
if [ $? == 0 ]; then
|
||||
|
@ -641,9 +644,11 @@ function WaitForTaskCompletion {
|
|||
Logger "Could not stop task with pid [$pid]." "ERROR"
|
||||
fi
|
||||
done
|
||||
if [ $noError != true ]; then
|
||||
SendAlert true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
for pid in "${pidsArray[@]}"; do
|
||||
if [ $(IsInteger $pid) -eq 1 ]; then
|
||||
|
|
Loading…
Reference in New Issue