Skip to content

Commit 743e4ae

Browse files
authored
Merge pull request #883 from github/restart-cron-on-restore-failure
on restore failure, restart cron on target host via trap call
2 parents bbfc42f + 6a94437 commit 743e4ae

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

bin/ghe-restore

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ while true; do
8686
esac
8787
done
8888

89+
start_cron () {
90+
echo "Starting cron ..."
91+
if $CLUSTER; then
92+
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then
93+
echo "* Warning: Failed to start cron on one or more nodes"
94+
fi
95+
else
96+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then
97+
echo "* Warning: Failed to start cron"
98+
fi
99+
fi
100+
}
101+
89102
cleanup () {
90103
if [ -n "$1" ]; then
91104
update_restore_status "$1"
@@ -103,6 +116,10 @@ cleanup () {
103116
fi
104117
fi
105118

119+
if ! $CRON_RUNNING; then
120+
start_cron
121+
fi
122+
106123
# Cleanup SSH multiplexing
107124
ghe-ssh --clean
108125
}
@@ -249,6 +266,7 @@ update_restore_status () {
249266
fi
250267
}
251268

269+
CRON_RUNNING=true
252270
# Update remote restore state file and setup failure trap
253271
trap "cleanup failed" EXIT
254272
update_restore_status "restoring"
@@ -324,7 +342,7 @@ else
324342
fi
325343
fi
326344
fi
327-
345+
CRON_RUNNING=false
328346

329347
# Restore settings and license if restoring to an unconfigured appliance or when
330348
# specified manually.
@@ -492,16 +510,8 @@ if ! $RESTORE_SETTINGS; then
492510
fi
493511

494512
# Start cron. Timerd will start automatically as part of the config run.
495-
echo "Starting cron ..."
496-
if $CLUSTER; then
497-
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then
498-
echo "* Warning: Failed to start cron on one or more nodes"
499-
fi
500-
else
501-
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then
502-
echo "* Warning: Failed to start cron"
503-
fi
504-
fi
513+
start_cron
514+
CRON_RUNNING=true
505515

506516
# Clean up all stale replicas on configured instances.
507517
if ! $CLUSTER && $instance_configured; then

0 commit comments

Comments
 (0)