Last active
July 28, 2017 06:56
-
-
Save Mikulas/633dff64110ba6a69c929ddcf7b11dec to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -uo pipefail | |
IFS=$'\n\t' | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
cd "$(dirname "$DIR")" | |
for RETRY in $(seq 1 120); do | |
OUT="$(php bin/console migrations:continue --production)" | |
STATUS="$?" | |
if [[ "$STATUS" -eq "0" ]]; then | |
# no error, migrations executed | |
echo "$OUT" | |
exit 0 | |
fi | |
if [[ $OUT != *"Unable to acquire a lock"* ]]; then | |
# error, but not lock error, do not retry | |
echo "$OUT" | |
exit "$STATUS" | |
fi | |
# lock is unavailable, another process is executing migrations, retry | |
echo "Unable to acquire a lock, retrying" | |
sleep 1 | |
done | |
echo "Failed to acquire a lock, stopped retrying" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment