【发布时间】:2019-05-02 02:04:00
【问题描述】:
我有一个带有 celery worker 和 beat 的 Django 应用,我很难在 ECS 上设置 celery(在 ECS 上配置 Django 应用非常简单,没有问题)。
1) 我应该为 worker 和 beat 使用什么样的服务:REPLICA还是DAEMON?
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
【问题讨论】:
-
我不明白是什么问题。假设您选择
REPLICA,没有 healthcheck 命令且没有 supervisord,究竟是什么不起作用?容器停止?可以分享日志吗? -
@ItayB 容器通过运行状况检查停止。看起来它在没有健康检查的情况下工作。我不相信我错过了。谢谢!
标签: django celery amazon-ecs celerybeat