-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
since celery is now required by notifications-api-common to send notifications
- Loading branch information
Showing
8 changed files
with
115 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
LOGLEVEL=${CELERY_LOGLEVEL:-INFO} | ||
|
||
QUEUE=${1:-${CELERY_WORKER_QUEUE:=celery}} | ||
WORKER_NAME=${2:-${CELERY_WORKER_NAME:="${QUEUE}"@%n}} | ||
|
||
# Figure out abspath of this script | ||
SCRIPT=$(readlink -f "$0") | ||
SCRIPTPATH=$(dirname "$SCRIPT") | ||
|
||
# wait for required services | ||
${SCRIPTPATH}/wait_for_db.sh | ||
|
||
# build up worker options array | ||
worker_options=( | ||
"-Q$QUEUE" | ||
"-n$WORKER_NAME" | ||
"-l$LOGLEVEL" | ||
"-Ofair" | ||
) | ||
|
||
if [[ -v CELERY_WORKER_CONCURRENCY ]]; then | ||
echo "Using concurrency ${CELERY_WORKER_CONCURRENCY}" | ||
worker_options+=( "-c${CELERY_WORKER_CONCURRENCY}" ) | ||
fi | ||
|
||
echo "Starting celery worker $WORKER_NAME with queue $QUEUE" | ||
exec celery \ | ||
--app objects \ | ||
--workdir src \ | ||
worker "${worker_options[@]}" |
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,15 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# Wait for the database container | ||
# See: https://docs.docker.com/compose/startup-order/ | ||
export PGHOST=${DB_HOST:-db} | ||
export PGPORT=${DB_PORT:-5432} | ||
|
||
until pg_isready; do | ||
>&2 echo "Waiting for database connection..." | ||
sleep 1 | ||
done | ||
|
||
>&2 echo "Database is up." |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: EUPL-1.2 | ||
# Copyright (C) 2022 Dimpact | ||
from celery import Celery | ||
|
||
from objects.setup import setup_env | ||
|
||
setup_env() | ||
|
||
app = Celery("objects") | ||
|
||
app.config_from_object("django.conf:settings", namespace="CELERY") | ||
app.autodiscover_tasks() |
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