我正在尝试配置ElasticBeanstalk以在Docker容器中运行Flask-RQ2工作者。因此,我在.ebextensions目录下创建了以下配置:
module.exports = routes()
.add('index', '/:lang?')
.add('tickets', '/:lang?/ticket')
.add('hotel', '/:lang?/hotel');
部署后,看不到工作程序正在运行。
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
并且在SSH下调用worker命令非常有效:
$ 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
我在做什么错了?
UPD
今天重新部署了该应用程序,该工作人员似乎已开始工作。
$ 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