Skip to content

Commit f1a0f62

Browse files
authored
Merge pull request #3 from DuncanDHall/patch-rsync-exit-status
Make sync-rsync.remotePath optional in VSCode config
2 parents fc87efb + e0961b3 commit f1a0f62

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

aliases

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function nom-cp() {
118118
[ $MAIN ] && RSYNC=true
119119
[ ! $MAIN ] && [ "$RSYNC_BRANCHES" ] && RSYNC=true
120120

121-
[ $RSYNC ] && ( set -x; rsync "$@" )
121+
[ $RSYNC ] && { set +e; set -x; rsync "$@"; RSYNC_EXIT=$?; set +x; set -e; }
122122

123123
# this is a special exception project where we DONT want to ALSO copy file to nomad deploy
124124
[ $MAIN ] && [ "$JOB" = "ia-petabox" ] && [ ! $NOM_CP_PETABOX_MAIN ] && exit 0
@@ -135,7 +135,27 @@ function nom-cp() {
135135
# (and thus hang). So timeout/kill after 2s :( tracey 2024/3 )
136136
set +e
137137
cat "$FILE" | ( set -x; set +e; nomad alloc exec -i -task $TASK "$ALLOC" sh -c "timeout 2 cat >| '$REST'" )
138-
echo SUCCESS
138+
NOMAD_EXIT=$?
139+
# timeout shoud come back with a 143, which we treat as success
140+
[ $NOMAD_EXIT -eq 143 ] && NOMAD_EXIT=0
141+
142+
if [ -n "${RSYNC_EXIT}" ]; then
143+
if [ ${RSYNC_EXIT} -ne 0 ]; then
144+
echo "Warning: rsync failed with exit code $RSYNC_EXIT"
145+
else
146+
echo "Info: rsync was successful"
147+
fi
148+
fi
149+
150+
if [ $NOMAD_EXIT -ne 0 ]; then
151+
echo "Warning: nomad sync failed with exit code $NOMAD_EXIT"
152+
else
153+
echo "Info: nomad sync was successful"
154+
fi
155+
156+
if [ ${RSYNC_EXIT:-0} -ne 0 ] || [ $NOMAD_EXIT -ne 0 ]; then
157+
return 1
158+
fi
139159
}
140160

141161

0 commit comments

Comments
 (0)