-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
94 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
#!/bin/bash | ||
|
||
printf "celery" >> /tmp/container-role | ||
|
||
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 as e: | ||
print(e) | ||
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 | ||
python manage.py load_redis_index | ||
|
||
|
||
touch /tmp/healthy | ||
|
||
watchmedo \ | ||
auto-restart --directory=./ --pattern=*.py --recursive -- \ | ||
celery --workdir="/app" -A config.celery_app worker -B --loglevel=INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#!/bin/bash | ||
printf "celery-worker" >> /tmp/container-role | ||
|
||
if [ -z "${DATABASE_URL}" ]; then | ||
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" | ||
fi | ||
|
||
|
||
touch /tmp/healthy | ||
|
||
celery --app=config.celery_app worker --max-tasks-per-child=6 --loglevel=info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
#!/bin/bash | ||
printf "celery-worker" >> /tmp/container-role | ||
|
||
if [ -z "${DATABASE_URL}" ]; then | ||
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" | ||
fi | ||
|
||
|
||
touch /tmp/healthy | ||
|
||
export NEW_RELIC_CONFIG_FILE=/etc/newrelic.ini | ||
newrelic-admin run-program celery --app=config.celery_app worker --max-tasks-per-child=6 --loglevel=info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
CONTAINER_ROLE=$(cat /tmp/container-role) | ||
if [[ "$CONTAINER_ROLE" = "api" ]]; then | ||
curl -f http://localhost:9000/health/ || exit 1 | ||
else | ||
# Health check for Worker/beat | ||
if [[ -f /tmp/healthy ]]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters