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

offload migrations to beat service #1710

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 24 additions & 0 deletions scripts/celery_beat-ecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,28 @@
if [ -z "${DATABASE_URL}" ]; then
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
fi

postgres_ready() {
python << END
import sys

import psycopg

try:
psycopg.connect(conninfo="${DATABASE_URL}")
except psycopg.OperationalError:
sys.exit(-1)
sys.exit(0)

END
}

until postgres_ready; do
>&2 echo 'Waiting for PostgreSQL to become available...'
sleep 1
done
>&2 echo 'PostgreSQL is available'

python manage.py migrate --noinput

celery --app=config.celery_app beat --loglevel=info
24 changes: 24 additions & 0 deletions scripts/celery_beat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,29 @@
if [ -z "${DATABASE_URL}" ]; then
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
fi

postgres_ready() {
python << END
import sys

import psycopg

try:
psycopg.connect(conninfo="${DATABASE_URL}")
except psycopg.OperationalError:
sys.exit(-1)
sys.exit(0)
sainak marked this conversation as resolved.
Show resolved Hide resolved

END
}

until postgres_ready; do
>&2 echo 'Waiting for PostgreSQL to become available...'
sleep 1
done
>&2 echo 'PostgreSQL is available'

python manage.py migrate --noinput

export NEW_RELIC_CONFIG_FILE=/etc/newrelic.ini
newrelic-admin run-program celery --app=config.celery_app beat --loglevel=info
1 change: 0 additions & 1 deletion scripts/start-ecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ done
>&2 echo 'PostgreSQL is available'

python manage.py collectstatic --noinput
python manage.py migrate --noinput
gunicorn config.wsgi:application --bind 0.0.0.0:9000 --chdir=/app --workers 2
3 changes: 1 addition & 2 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ until postgres_ready; do
done
>&2 echo 'PostgreSQL is available'

python manage.py collectstatic --noinput

export NEW_RELIC_CONFIG_FILE=/etc/newrelic.ini
python manage.py collectstatic --noinput
python manage.py migrate
newrelic-admin run-program gunicorn config.wsgi:application --bind 0.0.0.0:9000 --chdir=/app
Loading