From a9588bebc7dad65155bb24e2082310aafcf8f944 Mon Sep 17 00:00:00 2001 From: Novy Ondrej Date: Sat, 28 Mar 2015 21:37:51 +0100 Subject: [PATCH 1/2] Run sync after timeout in inotify mode even when no changes detected. --- osync.sh | 16 +++++++++++++--- sync.conf | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/osync.sh b/osync.sh index 6ba5cf0..632e487 100755 --- a/osync.sh +++ b/osync.sh @@ -1993,11 +1993,21 @@ function SyncOnChanges fi Log "#### Monitoring now." - inotifywait --exclude $OSYNC_DIR $RSYNC_EXCLUDE -qq -r -e create -e modify -e delete -e move -e attrib "$MASTER_SYNC_DIR" & + inotifywait --exclude $OSYNC_DIR $RSYNC_EXCLUDE -qq -r -e create -e modify -e delete -e move -e attrib --timeout "$MAX_WAIT" "$MASTER_SYNC_DIR" & sub_pid=$! wait $sub_pid - Log "#### Changes detected, waiting $MIN_WAIT seconds before running next sync." - sleep $MIN_WAIT + retval=$? + if [ $retval == 0 ] + then + Log "#### Changes detected, waiting $MIN_WAIT seconds before running next sync." + sleep $MIN_WAIT + elif [ $retval == 2 ] + then + Log "#### $MAX_WAIT timeout reached, running sync." + else + Log "#### inotify error detected, waiting $MIN_WAIT seconds before running next sync." + sleep $MIN_WAIT + fi done } diff --git a/sync.conf b/sync.conf index bc8bef2..c1e12ad 100755 --- a/sync.conf +++ b/sync.conf @@ -87,6 +87,10 @@ HARD_MAX_EXEC_TIME=10600 ## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish. MIN_WAIT=60 +## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run. +## Use 0 to wait indefinitely. +MAX_WAIT=300 + ## ---------- BACKUP AND DELETION OPTIONS ## Enabling this option will keep a backup of a file on the target replica if it gets updated from the source replica. Backups will be made to .osync_workdir/backups From 8bc5b5ee682dd7a480e2d014d90f9d2c97eeaa4e Mon Sep 17 00:00:00 2001 From: onovy Date: Sat, 28 Mar 2015 22:44:41 +0100 Subject: [PATCH 2/2] Locking fix in SyncOnChanges mode. --- osync.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osync.sh b/osync.sh index 632e487..a139f66 100755 --- a/osync.sh +++ b/osync.sh @@ -1980,9 +1980,9 @@ function SyncOnChanges do if [ "$ConfigFile" != "" ] then - cmd="bash $osync_cmd \"$ConfigFile\" $opts --no-locks" + cmd="bash $osync_cmd \"$ConfigFile\" $opts" else - cmd="bash $osync_cmd $opts --no-locks" + cmd="bash $osync_cmd $opts" fi eval $cmd retval=$? @@ -2096,6 +2096,7 @@ do ;; --on-changes) sync_on_changes=1 + nolocks=1 ;; --no-locks) nolocks=1