Skip to content

Commit 3d27a10

Browse files
authored
Merge pull request #269 from github/snh/stop-services-2
Stop cron and timerd during restore #2
2 parents e6409c4 + e1363db commit 3d27a10

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

bin/ghe-restore

+36
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,28 @@ fi
200200
ghe-backup-store-version ||
201201
echo "Warning: storing backup-utils version remotely failed."
202202

203+
# Stop cron and timerd, as scheduled jobs may disrupt the restore process.
204+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
205+
echo "Stopping cron and github-timerd ..."
206+
if $cluster; then
207+
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then
208+
ghe_verbose "* Warning: Failed to stop cron on one or more nodes"
209+
fi
210+
211+
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then
212+
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
213+
fi
214+
else
215+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then
216+
ghe_verbose "* Warning: Failed to stop cron"
217+
fi
218+
219+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then
220+
ghe_verbose "* Warning: Failed to stop github-timerd"
221+
fi
222+
fi
223+
fi
224+
203225
# Restore settings and license if restoring to an unconfigured appliance or when
204226
# specified manually.
205227
if $restore_settings; then
@@ -323,6 +345,20 @@ elif $instance_configured; then
323345
fi
324346
fi
325347

348+
# Start cron. Timerd will start automatically as part of the config run.
349+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
350+
echo "Starting cron ..."
351+
if $cluster; then
352+
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then
353+
echo "* Warning: Failed to start cron on one or more nodes"
354+
fi
355+
else
356+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then
357+
echo "* Warning: Failed to start cron"
358+
fi
359+
fi
360+
fi
361+
326362
# Update the remote status to "complete". This has to happen before importing
327363
# ssh host keys because subsequent commands will fail due to the host key
328364
# changing otherwise.

test/bin/service

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
# Fake service command for tests.
3+
true

0 commit comments

Comments
 (0)