synchro.sh: sync files in a separate thread

This commit is contained in:
nemunaire 2020-01-16 15:55:08 +01:00
parent aba311aebd
commit e7c1812cb0

View File

@ -10,16 +10,20 @@ SSH_OPTS="/usr/bin/ssh -p 22 -i ~/.ssh/id_ed25519 -o ControlMaster=auto -o Contr
cd "${BASEDIR}" cd "${BASEDIR}"
# Synchronize CA
rsync -e "$SSH_OPTS" -av --delete PKI/shared "${FRONTEND_HOSTNAME}":"${BASEDIR}"/PKI
I=0
touch /tmp/stop touch /tmp/stop
# Synchronize static files in a separate loop (to avoid submissions delays during file synchronization)
while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ]
do
rsync -e "$SSH_OPTS" -av --delete FILES "${FRONTEND_HOSTNAME}":"${BASEDIR}"
sleep 5
done &
while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ] while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ]
do do
# Synchronize static files pages # Synchronize static files pages
rsync -e "$SSH_OPTS" -av --delete TEAMS SETTINGS FILES "${FRONTEND_HOSTNAME}":"${BASEDIR}" rsync -e "$SSH_OPTS" -av --delete PKI TEAMS SETTINGS "${FRONTEND_HOSTNAME}":"${BASEDIR}"
# Synchronize submissions # Synchronize submissions
rsync -e "$SSH_OPTS" -av --ignore-existing --delay-updates --temp-dir=.tmp/ --partial-dir=.tmp/ --remove-source-files "${FRONTEND_HOSTNAME}":"${BASEDIR}"/submissions/ submissions/ rsync -e "$SSH_OPTS" -av --ignore-existing --delay-updates --temp-dir=.tmp/ --partial-dir=.tmp/ --remove-source-files "${FRONTEND_HOSTNAME}":"${BASEDIR}"/submissions/ submissions/
@ -27,4 +31,5 @@ do
sleep 0.3 sleep 0.3
done done
wait
echo See you echo See you