在 AWS ECS 上设置 celery worker 和 celery beat (django app)

Setup celery worker and celery beat (django app) on AWS ECS

我有一个带有 celery worker 和 beat 的 Django 应用程序,我很难尝试在 ECS 上设置 celery(ECS 上的 Django 应用程序的配置非常简单,没问题)。

1) 我应该为 worker 使用什么样的 servicebeat: REPLICADAEMON?

2) 我可以对 任务定义 配置上的 Healthcheck 使用什么命令?

我尝试使用 supervisor 并在任务定义的命令部分直接调用 celery 命令。

我不知道我到底错过了什么...

supervisor.conf:

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                      ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; supervisord log file
logfile_maxbytes=50MB       ; maximum size of logfile before rotation
logfile_backups=10          ; number of backed up logfiles
loglevel=debug               ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false              ; run supervisord as a daemon
minfds=1024                 ; number of startup file descriptors
minprocs=200                ; number of process descriptors
user=root                   ; default user
childlogdir=/var/log/supervisor/            ; where child log files will live

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
[include]
files = /etc/supervisor/conf.d/*.conf

celeryworker.conf:

[program:celery]
command=/start-worker.sh

directory=/app
user=myuser
numprocs=1
stdout_logfile=/var/log/app_logs/celery-worker.log
stderr_logfile=/var/log/app_logs/celery-worker.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600

stopasgroup=true

priority=1000

celerybeat.conf:

[program:celerybeat]
command=/start-beat.sh

directory=/app
user=myuser
numprocs=1
stdout_logfile=/var/log/app_logs/celery-beat.log
stderr_logfile=/var/log/app_logs/celery-beat.log
autostart=true
autorestart=true
startsecs=10
process group.

stopasgroup=true

priority=999

start-worker.sh:

#!/usr/bin/env bash
celery -A my_app worker -l ${APP_LOG_LEVEL} -n worker.%%h

start-beat.sh:

#!/usr/bin/env bash
celery -A my_app beat -l ${APP_LOG_LEVEL} --workdir=/app --schedule django

刚刚创建了具有最小健康百分比的服务 = 0和任务定义没有健康检查 正如@ItayB 所指出的。 我还删除了主管设置。