Skip to content

Commit

Permalink
Add default celery configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 committed Jul 27, 2023
1 parent dd8eea6 commit d7cac92
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
15 changes: 13 additions & 2 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,18 @@
CELERY_BROKER_URL = env("CELERY_BROKER_URL", default="django://")
# https://docs.celeryproject.org/en/stable/userguide/optimizing.html#broker-connection-pools
# https://docs.celeryq.dev/en/latest/userguide/optimizing.html#broker-connection-pools
CELERY_BROKER_POOL_LIMIT = env(
"CELERY_BROKER_POOL_LIMIT", default=env("CELERYD_CONCURRENCY", default=1000)
# Configured to 0 due to connection issues https://github.com/celery/celery/issues/4355
CELERY_BROKER_POOL_LIMIT = env.int("CELERY_BROKER_POOL_LIMIT", default=0)
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-heartbeat
CELERY_BROKER_HEARTBEAT = env.int("CELERY_BROKER_HEARTBEAT", default=0)

# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-broker_connection_max_retries
CELERY_BROKER_CONNECTION_MAX_RETRIES = env.int(
"CELERY_BROKER_CONNECTION_MAX_RETRIES", default=0
)
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-channel-error-retry
CELERY_BROKER_CHANNEL_ERROR_RETRY = env.bool(
"CELERY_BROKER_CHANNEL_ERROR_RETRY", default=True
)
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = env("CELERY_RESULT_BACKEND", default="redis://")
Expand All @@ -234,6 +244,7 @@
CELERY_TASK_QUEUE_MAX_PRIORITY = 10
# https://docs.celeryproject.org/en/latest/userguide/configuration.html#broker-transport-options
CELERY_BROKER_TRANSPORT_OPTIONS = {}

# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_routes
CELERY_ROUTES = (
[
Expand Down
4 changes: 3 additions & 1 deletion docker/web/celery/scheduler/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ fi
sleep 10

echo "==> $(date +%H:%M:%S) ==> Running Celery beat <=="
exec celery -C -A config.celery_app beat -S django_celery_beat.schedulers:DatabaseScheduler --loglevel $log_level
exec celery -C -A config.celery_app beat \
-S django_celery_beat.schedulers:DatabaseScheduler \
--loglevel $log_level
3 changes: 2 additions & 1 deletion docker/web/celery/worker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ exec celery -C -A config.celery_app worker \
--concurrency=${TASK_CONCURRENCY} \
--max-memory-per-child=${MAX_MEMORY_PER_CHILD} \
--max-tasks-per-child=${MAX_TASKS_PER_CHILD} \
-Q "$WORKER_QUEUES"
--without-heartbeat --without-gossip \
--without-mingle -Q "$WORKER_QUEUES"

0 comments on commit d7cac92

Please sign in to comment.