Celery Elastic Beanstalk importterror:不能导入名称为“芹菜”的文件



我正试图通过Django让芹菜在Elastic Beanstalk上工作,但没有多少运气。

我可以在我的本地机器上使用芹菜,但是每当我部署到Elastic Beanstalk时,它就不像这一行:

我看了一些关于这个的其他问题,他们说把我的python文件celery.py的名字改成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,所以我假设库已经安装。

在requirements.txt中也需要django-芹菜。

更新:我们也在部署后重新启动我们的芹菜服务。

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

显然,您需要将芹菜设置为守护进程,以及整个部分。

相关内容

  • 没有找到相关文章

最新更新