python-3.x - 无法在 AWS ElasticBeanstalk 上运行后台工作程序
问题描述
我正在尝试将 ElasticBeanstalk 配置为在 Docker 容器内运行 Flask-RQ2 工作程序。因此,我在 .ebextensions 目录下创建了以下配置:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_workers.sh":
mode: "000755"
owner: root
group: root
content: |
#nohup docker exec $(docker ps | grep $(docker images -q aws_beanstalk/current-app) | awk '{print $1}') flask rq worker > /dev/null 2>&1 &
container_commands:
001-run-worker:
leader_only: true
command: "sed -i -e 's/#//' /opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_workers.sh"
ignoreErrors: true
部署后,它无法看到工作人员正在运行。
$ docker exec $(docker ps | grep $(docker images -q aws_beanstalk/current-app) | awk '{print $1}') flask rq info
default | 0
1 queues, 0 jobs total
0 workers, 1 queues
Updated: 2019-01-31 19:44:13.182584
在 SSH 下调用 worker 命令效果很好:
$ docker exec $(docker ps | grep $(docker images -q aws_beanstalk/current-app) | awk '{print $1}') flask rq worker
[2019-01-31 19:46:04,618] INFO in worker: RQ worker 'rq:worker:72892ec44d9b.66' started, version 0.13.0
[2019-01-31 19:46:04,620] INFO in worker: *** Listening on default...
[2019-01-31 19:46:04,621] INFO in worker: Cleaning registries for queue: default
我究竟做错了什么?
UPD
今天重新部署了应用程序,工人似乎已启动。
$ docker exec $(docker ps | grep $(docker images -q aws_beanstalk/current-app) | awk '{print $1}') flask rq info
default | 0
1 queues, 0 jobs total
f89e0061ba39.13 idle: default
1 workers, 1 queues
Updated: 2019-02-01 08:24:40.154956
解决方案
推荐阅读
- c# - C# 当创建一个类的数组时,我得到 System.NullReferenceException
- java - 需要花费大量时间才能检索的列表
- c# - 需要帮助序列化/反序列化此 JSON
- asp.net-mvc - 以美元显示货币
- reactjs - 元素类型无效:应为字符串(用于内置组件)或类/函数(用于复合组件)但得到:未定义
- scala - Scala:在scala中检查变量是否为整数
- sql-server - SP_Execute 未在输出参数中返回值
- javascript - 有没有更好的方法在一个 html 页面上多次运行 JavaScript?
- yocto - Yocto中populate_sdk时如何排除包
- maven - 如何在 teamcity SonarQube runner 中列出子模块