mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
wait for migrations in awx-web container
This commit is contained in:
parent
a21dcec85d
commit
041e22f609
@ -3,7 +3,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
@ -36,7 +35,6 @@ else:
|
||||
from django.db.models import indexes
|
||||
from django.db.backends.utils import names_digest
|
||||
from django.db import connection
|
||||
from django.db.utils import OperationalError
|
||||
|
||||
|
||||
if HAS_DJANGO is True:
|
||||
@ -154,19 +152,6 @@ def manage():
|
||||
|
||||
# enforce the postgres version is equal to 12. if not, then terminate program with exit code of 1
|
||||
if not MODE == 'development':
|
||||
# wait for connection to the database
|
||||
sys.stdout.write("Wainting for connection to database\n")
|
||||
connected = False
|
||||
while not connected:
|
||||
try:
|
||||
connection.ensure_connection()
|
||||
connected = True
|
||||
except OperationalError:
|
||||
sys.stdout.write("No connection available\n")
|
||||
time.sleep(1)
|
||||
|
||||
sys.stdout.write("Connection established\n")
|
||||
|
||||
if (connection.pg_version // 10000) < 12:
|
||||
sys.stderr.write("Postgres version 12 is required\n")
|
||||
sys.exit(1)
|
||||
|
||||
@ -13,6 +13,8 @@ if [ -n "${AWX_KUBE_DEVEL}" ]; then
|
||||
export SDB_NOTIFY_HOST=$MY_POD_IP
|
||||
fi
|
||||
|
||||
wait-for-migrations || exit 1
|
||||
|
||||
awx-manage collectstatic --noinput --clear
|
||||
|
||||
supervisord -c /etc/supervisord.conf
|
||||
|
||||
@ -13,6 +13,6 @@ if [ -n "${AWX_KUBE_DEVEL}" ]; then
|
||||
export SDB_NOTIFY_HOST=$MY_POD_IP
|
||||
fi
|
||||
|
||||
wait-for-migrations
|
||||
wait-for-migrations || exit 1
|
||||
|
||||
supervisord -c /etc/supervisord_task.conf
|
||||
|
||||
@ -22,13 +22,20 @@ wait_for() {
|
||||
local rc=1
|
||||
local attempt=1
|
||||
local next_sleep="${MIN_SLEEP}"
|
||||
local check=1
|
||||
|
||||
while true; do
|
||||
log_message "Attempt ${attempt} of ${ATTEMPTS}"
|
||||
|
||||
timeout "${TIMEOUT}" \
|
||||
/bin/bash -c "! awx-manage showmigrations | grep '\[ \]'" &>/dev/null \
|
||||
&& return || rc=$?
|
||||
/bin/bash -c "awx-manage check" &>/dev/null
|
||||
check=$?
|
||||
|
||||
if [ $check -eq 0 ]; then
|
||||
timeout "${TIMEOUT}" \
|
||||
/bin/bash -c "! awx-manage showmigrations | grep '\[ \]'" &>/dev/null \
|
||||
&& return || rc=$?
|
||||
fi
|
||||
|
||||
(( ++attempt > ATTEMPTS )) && break
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user