Skip to content

Instantly share code, notes, and snippets.

@Mikulas
Last active July 28, 2017 06:56
Show Gist options
  • Save Mikulas/633dff64110ba6a69c929ddcf7b11dec to your computer and use it in GitHub Desktop.
Save Mikulas/633dff64110ba6a69c929ddcf7b11dec to your computer and use it in GitHub Desktop.
#!/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