我正在尝试让芹菜通过Django在Elastic Beanstalk上工作,但没有太多运气。
我可以在我的本地机器上使用celery,但每当我部署到Elastic Beanstalk时,它都不喜欢这行:来自celery import Celery。
我看了几个关于这个问题的其他问题,他们说要将我的celery.py python文件的名称更改为celeryapp.py,但这不会改变结果。
完整的错误消息是:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/opt/python/run/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/opt/python/bundle/3/app/MY_PROJECT/__init__.py", line 5, in <module>
from .celery import app as celery_app
File "/opt/python/bundle/3/app/MY_PROJECT/celery.py", line 5, in <module>
from celery import Celery
File "/opt/python/current/app/MY_PROJECT/celery.py", line 5, in <module>
from celery import Celery
ImportError: cannot import name Celery
(ElasticBeanstalk::ExternalInvocationError)
任何人都知道为什么芹菜不能进口芹菜?在我的requirements.txt中,我有芹菜== 3.1.18,所以我假设已经安装了库。
答案 0 :(得分:0)
你也需要在requirements.txt中使用django-celery。
更新: 我们也重新启动芹菜服务部署。
commands:
90_create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh":
mode: "000755"
owner: root
group: users
content: |
#!/usr/bin/env bash
service celeryd restart
你显然需要设置celery作为一个守护进程运行,以及那一点。