Skip to content

Stop cron and timerd during restore #2 #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions bin/ghe-restore
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,28 @@ fi
ghe-backup-store-version ||
echo "Warning: storing backup-utils version remotely failed."

# Stop cron and timerd, as scheduled jobs may disrupt the restore process.
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
echo "Stopping cron and github-timerd ..."
if $cluster; then
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then
ghe_verbose "* Warning: Failed to stop cron on one or more nodes"
fi

if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
fi
else
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then
ghe_verbose "* Warning: Failed to stop cron"
fi

if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then
ghe_verbose "* Warning: Failed to stop github-timerd"
fi
fi
fi

# Restore settings and license if restoring to an unconfigured appliance or when
# specified manually.
if $restore_settings; then
Expand Down Expand Up @@ -323,6 +345,20 @@ elif $instance_configured; then
fi
fi

# Start cron. Timerd will start automatically as part of the config run.
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
echo "Starting cron ..."
if $cluster; then
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then
echo "* Warning: Failed to start cron on one or more nodes"
fi
else
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then
echo "* Warning: Failed to start cron"
fi
fi
fi

# Update the remote status to "complete". This has to happen before importing
# ssh host keys because subsequent commands will fail due to the host key
# changing otherwise.
Expand Down
3 changes: 3 additions & 0 deletions test/bin/service
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# Fake service command for tests.
true