Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase wait during initialization #1276

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading