-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10515 from cdrini/check-crons-deploy
Fix bug with check crons in deploy.sh
- Loading branch information
Showing
1 changed file
with
22 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ set -e | |
SERVER_SUFFIX=${SERVER_SUFFIX:-""} | ||
SERVER_NAMES=${SERVERS:-"ol-home0 ol-covers0 ol-web0 ol-web1 ol-web2 ol-www0"} | ||
SERVERS=$(echo $SERVER_NAMES | sed "s/ /$SERVER_SUFFIX /g")$SERVER_SUFFIX | ||
KILL_CRON=${KILL_CRON:-""} | ||
|
||
# Install GNU parallel if not there | ||
# Check is GNU-specific because some hosts had something else called parallel installed | ||
|
@@ -36,18 +37,6 @@ if ! command -v jq &> /dev/null; then | |
exit 1 | ||
fi | ||
|
||
# Check if any critical cron jobs are running: | ||
CRITICAL_JOBS="oldump.sh|expire_accounts.py|manage-imports.py|process_partner_data.sh|update_stale_work_references.py|promise_batch_imports.py" | ||
|
||
RUNNING_CRONS=$(ssh ol-home0.us.archive.org docker exec openlibrary-cron-jobs-1 ps -ef | grep -v grep | grep -E "$CRITICAL_JOBS") | ||
KILL_CRON=${KILL_CRON:-""} | ||
|
||
# If KILL_CRON is an empty string and there are running jobs, exit early | ||
if [ -z "$KILL_CRON" ] && [ -n "$RUNNING_CRONS" ]; then | ||
echo "Critical cron jobs are currently running. Halting deployment" | ||
exit 1 | ||
fi | ||
|
||
cleanup() { | ||
TMP_DIR=$1 | ||
echo "" | ||
|
@@ -69,6 +58,25 @@ wait_yn() { | |
done | ||
} | ||
|
||
check_crons() { | ||
# Check if any critical cron jobs are running: | ||
CRITICAL_JOBS="oldump.sh|process_partner_data.sh|update_stale_work_references.py|promise_batch_imports.py" | ||
|
||
echo "" | ||
echo -n "Checking for running critical cron jobs... " | ||
RUNNING_CRONS=$(ssh ol-home0.us.archive.org ps -ef | grep -v grep | grep -E "$CRITICAL_JOBS") | ||
|
||
# If KILL_CRON is an empty string and there are running jobs, exit early | ||
if [ -z "$KILL_CRON" ] && [ -n "$RUNNING_CRONS" ]; then | ||
echo "✗" | ||
echo "Critical cron jobs are currently running. Halting deployment:" | ||
echo "$RUNNING_CRONS" | ||
exit 1 | ||
else | ||
echo "✓" | ||
fi | ||
} | ||
|
||
check_for_local_changes() { | ||
SERVER=$1 | ||
REPO_DIR=$2 | ||
|
@@ -159,6 +167,7 @@ deploy_olsystem() { | |
echo "Deploying to: $SERVERS" | ||
|
||
check_server_access | ||
check_crons | ||
|
||
TMP_DIR=${TMP_DIR:-$(mktemp -d)} | ||
cd $TMP_DIR | ||
|
@@ -269,6 +278,7 @@ deploy_openlibrary() { | |
git -C openlibrary push [email protected]:internetarchive/openlibrary.git $DEPLOY_TAG | ||
|
||
check_server_access | ||
check_crons | ||
|
||
echo "Checking for changes in the openlibrary repo on the servers..." | ||
for SERVER in $SERVERS; do | ||
|