我花了一整天的时间来研究这个问题,但还是没有弄明白。虽然我遵循了正确的命令,正如celery 医生所说:celery -A tasks worker -l info
但我仍然收到一个错误,说
You are using `-A` as an option of the worker sub-command:
celery worker -A celeryapp <...>
The support for this usage was removed in Celery 5.0. Instead you should use `-A` as a global option:
celery -A celeryapp worker <...>
在我的Celery的Dockerfile中,我执行Celery的命令是:
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info"]
在Heroku资源中,它仍然显示预期的命令:
但是当Heroku正在建造时,我收到了这个错误
2021-10-06T15:33:34.586677+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2021-10-06T15:33:34.937996+00:00 heroku[celery_worker.1]: Starting process with command `celery -A tasks worker -l info`
2021-10-06T15:33:35.568289+00:00 heroku[celery_worker.1]: State changed from starting to up
2021-10-06T15:33:35.839353+00:00 heroku[web.1]: State changed from starting to up
2021-10-06T15:33:35.598861+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-10-06T15:33:35.599401+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [4] [INFO] Listening at: http://0.0.0.0:21157 (4)
2021-10-06T15:33:35.599471+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [4] [INFO] Using worker: sync
2021-10-06T15:33:35.604608+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [6] [INFO] Booting worker with pid: 6
2021-10-06T15:33:43.827079+00:00 app[celery_worker.1]: You are using `-A` as an option of the worker sub-command:
2021-10-06T15:33:43.827086+00:00 app[celery_worker.1]: celery worker -A celeryapp <...>
2021-10-06T15:33:43.827086+00:00 app[celery_worker.1]:
2021-10-06T15:33:43.827093+00:00 app[celery_worker.1]: The support for this usage was removed in Celery 5.0. Instead you should use `-A` as a global option:
2021-10-06T15:33:43.827093+00:00 app[celery_worker.1]: celery -A celeryapp worker <...>
2021-10-06T15:33:43.830304+00:00 app[celery_worker.1]: Usage: celery worker [OPTIONS]
2021-10-06T15:33:43.830306+00:00 app[celery_worker.1]: Try 'celery worker --help' for help.
2021-10-06T15:33:43.830307+00:00 app[celery_worker.1]:
2021-10-06T15:33:43.831352+00:00 app[celery_worker.1]: Error: no such option: -A
我在配置中做错了什么或缺少了什么吗?
我很乐意得到你的帮助。先谢谢你了。
1条答案
按热度按时间flvlnr441#
我在一个几年没碰过的老堆栈上工作时被这个问题难倒了。
在我的例子中,我使用supervisor运行celery,在更新
/etc/supervisor/conf.d/appname-celery.conf
文件中的celery命令后,我需要运行两个supervisor命令。本文档中介绍了这些命令,如下所示:
我可以通过使命令行无效,向celery的预期位置添加一些随机字符来测试我的supervisor配置更新没有被选中。
另一种我知道出错的方法是在正确的虚拟环境中从命令行运行“正确的”命令。这样做,我可以看到celery 开始如预期。
它采取了一些挖掘到上述做步行通过。tldr;它不是celery,而是supervisor使用的缓存配置,它正在运行celery。