Celery 可以在 Elastic Beanstalk 上运行吗?

Kri*_*pta 5 django amazon-web-services celery amazon-elasticache amazon-elastic-beanstalk

我正在寻找一种在 Elastic Beanstalk 环境中运行 Celery 的直接方法。这是否存在,还是我需要改用 SQS?

我试过在 .config 文件中放一行,但没有很好的结果。这是我的 .config 文件:

container_commands:   
  01_syncdb:
    command: "django-admin.py syncdb --noinput"
    leader_only: true   
  02_collectstatic:
    command: "./manage.py collectstatic --noinput"   
  03_migrate:
    command: "./manage.py migrate --noinput"   
  04_start_celery:
    command: "./manage.py celery worker &"
Run Code Online (Sandbox Code Playgroud)

当我通过 SSH 连接到 EC2 服务器并运行时,ps -ef | grep celery它显示 Celery 没有运行。

任何帮助表示赞赏。谢谢!

Vic*_*ang 5

Celery 没有出现,因为容器命令是在部署期间重新启动网络服务器之前运行的。基本上,您的 celery 工人在机器重新启动后就会被消灭。

我建议使用部署后挂钩来启动 celery。

请参阅http://junkheap.net/blog/2013/05/20/elastic-beanstalk-post-deployment-scripts/以及如何使用 AWS Elastic Beanstalk 运行工作线程?