Skip to content

Commit

Permalink
increase wait during initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith committed Dec 29, 2024
1 parent 9906654 commit 435ea91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/library/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 10 additions & 10 deletions backend/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$(<db/django_secret_key)
echo "Django secret key read from file"
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=$(<db/django_secret_key)
echo "Django secret key read from file"
fi

while ! python manage.py showmigrations iam >/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
2 changes: 1 addition & 1 deletion update-ciso-assistant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}}")
Expand Down

0 comments on commit 435ea91

Please sign in to comment.