l sync-containers3: use atomic and nicer rsync
This commit is contained in:
parent
ad1320ce80
commit
f76693049d
@ -104,9 +104,8 @@ in {
|
|||||||
consul lock sync_${ctr.name} ${pkgs.writers.writeDash "${ctr.name}-sync" ''
|
consul lock sync_${ctr.name} ${pkgs.writers.writeDash "${ctr.name}-sync" ''
|
||||||
set -efux
|
set -efux
|
||||||
if /run/wrappers/bin/ping -c 1 ${ctr.name}.r; then
|
if /run/wrappers/bin/ping -c 1 ${ctr.name}.r; then
|
||||||
touch "$HOME"/incomplete
|
nice --adjustment=30 rsync -a -e "ssh -i $CREDENTIALS_DIRECTORY/ssh_key" --timeout=30 container_sync@${ctr.name}.r:disk "$HOME"/disk
|
||||||
rsync -a -e "ssh -i $CREDENTIALS_DIRECTORY/ssh_key" --timeout=30 --inplace container_sync@${ctr.name}.r:disk "$HOME"/disk
|
rm -f "$HOME"/incomplete
|
||||||
rm "$HOME"/incomplete
|
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
@ -218,10 +217,6 @@ in {
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if test -e /var/lib/sync-containers3/${ctr.name}/incomplete; then
|
|
||||||
echo 'data is inconistent, start aborted'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
consul kv put containers/${ctr.name} "$(jq -cn '{host: "${config.networking.hostName}", time: now}')" >/dev/null
|
consul kv put containers/${ctr.name} "$(jq -cn '{host: "${config.networking.hostName}", time: now}')" >/dev/null
|
||||||
consul lock -verbose -monitor-retry=100 -timeout 30s -name container_${ctr.name} container_${ctr.name} ${pkgs.writers.writeBash "${ctr.name}-start" ''
|
consul lock -verbose -monitor-retry=100 -timeout 30s -name container_${ctr.name} container_${ctr.name} ${pkgs.writers.writeBash "${ctr.name}-start" ''
|
||||||
set -efu
|
set -efu
|
||||||
|
Loading…
Reference in New Issue
Block a user