在生产环境中重新构建和重新启动cookiecutter-django docker-compose时,我遇到了这个问题。我可以通过删除所有停止的docker容器或者在类似于/compose/local/django/celery/beat/start.sh的/compose/production/django/celery/beat/start.sh中添加rm -f './celerybeat.pid'来解决这个问题。有没有什么理由不在compose文件的生产版本中包含这个特定的代码?
发布于 2019-11-24 02:24:43
发布于 2020-06-24 21:34:58
之前有一篇关于如何通过在运行命令中将PID文件设置为空值来修复这个问题的文章,但解决方案并不完整,我花了一点时间才让它在我的生产系统上工作,所以我想我应该发布一个docker-compose文件,其中包含一个beats服务,该服务通过一个命令运行,以便在启动时创建一个新的celerybeats.pid文件。
请注意,我使用的是django-celery-beat:https://pypi.org/project/django-celery-beat/
version: '3'
services:
redis:
image: redis
restart: unless-stopped
ports:
- "6379"
beats:
build: .
user: user1
# note the --pidfile= in this command
command: celery --pidfile= -A YOURPROJECT beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
env_file: ./.env.prod
restart: unless-stopped
volumes:
- .:/code
- tmp:/tmp
links:
- redis
depends_on:
- redis
volumes:
tmp:执行此操作后,我不再收到ERROR: Pidfile (celerybeat.pid) already exists错误,也不必运行rm命令。
发布于 2018-11-29 00:27:30
您可以使用celery worker --pidfile=/path/to/celeryd.pid指定未装载的路径,使其不会镜像到主机上。
https://stackoverflow.com/questions/50381953
复制相似问题