From 435ea918f2d6576fcbc1abce4a27bb35b780ed30 Mon Sep 17 00:00:00 2001 From: Abderrahmane Smimite Date: Sun, 29 Dec 2024 22:36:09 +0100 Subject: [PATCH] increase wait during initialization --- backend/library/utils.py | 2 +- backend/startup.sh | 20 ++++++++++---------- update-ciso-assistant.sh | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/library/utils.py b/backend/library/utils.py index e39b2eb41..161a1a0ff 100644 --- a/backend/library/utils.py +++ b/backend/library/utils.py @@ -678,7 +678,7 @@ def import_library(self): break except OperationalError as e: if e.args and e.args[0] == "database is locked": - time.sleep(1) + time.sleep(3) else: raise e except Exception as e: diff --git a/backend/startup.sh b/backend/startup.sh index 0e5de7a01..415ad67d5 100755 --- a/backend/startup.sh +++ b/backend/startup.sh @@ -2,27 +2,27 @@ # wait for database to be ready if [ ! -n "$DJANGO_SETTINGS_MODULE" ]; then - export DJANGO_SETTINGS_MODULE=ciso_assistant.settings + export DJANGO_SETTINGS_MODULE=ciso_assistant.settings fi if [ ! -n "$DJANGO_SECRET_KEY" ]; then - if [ ! -f db/django_secret_key ]; then - install -m 600 <(cat /proc/sys/kernel/random/uuid) db/django_secret_key - echo "generating initial Django secret key" - fi - export DJANGO_SECRET_KEY=$(/dev/null; do - echo "database not ready; waiting" - sleep 10 + echo "database not ready; waiting" + sleep 20 done poetry run python manage.py migrate --settings="${DJANGO_SETTINGS_MODULE}" poetry run python manage.py storelibraries --settings="${DJANGO_SETTINGS_MODULE}" if [ -n "$DJANGO_SUPERUSER_EMAIL" ]; then - poetry run python manage.py createsuperuser --noinput --settings="${DJANGO_SETTINGS_MODULE}" + poetry run python manage.py createsuperuser --noinput --settings="${DJANGO_SETTINGS_MODULE}" fi exec gunicorn --chdir ciso_assistant --bind :8000 --timeout 300 --env RUN_MAIN=true ciso_assistant.wsgi:application diff --git a/update-ciso-assistant.sh b/update-ciso-assistant.sh index 95bd275f5..f2ea96e3b 100755 --- a/update-ciso-assistant.sh +++ b/update-ciso-assistant.sh @@ -40,7 +40,7 @@ docker compose up -d # Wait for the database to be ready echo "Giving some time for the database to be ready, please wait ..." -sleep 30 +sleep 50 # Apply migrations BACKEND_CONTAINER=$(docker ps --filter "ancestor=$BACKEND_IMAGE" --format "{{.Names}}")