如何在不退出的情况下在AWS ECS上运行节点容器

我努力让我的node.js容器在ECS上运行。 当我用Docker组合本地运行它时,它运行良好,但在ECS上它运行2-3分钟,并处理一些连接(负载平衡器中的2-3次健康检查),然后closures。 我无法弄清楚为什么。

我的Dockerfile –

FROM node:6.10 RUN npm install -g nodemon \ && npm install forever-monitor \ winston \ express-winston RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package.json /usr/src/app/ RUN npm install COPY . /usr/src/app EXPOSE 3000 CMD [ "npm", "start" ] 

然后在我的package.json中 –

 { ... "main": "forever.js", "dependencies": { "mongodb": "~2.0", "abbajs": ">=0.1.4", "express": ">=4.15.2" } ... } 

在我的docker-compose.yml中运行nodemon –

 node: ... command: nodemon 

在我的cloudWatch日志中,我可以看到一切都开始 –

 14:20:24 npm info lifecycle my_app@1.0.0~start: my_app@1.0.0 

然后我看到健康检查请求(都是用http 200的),稍后一切都会结束 –

 14:23:00 npm info lifecycle mapov_reporting@1.0.0~poststart: mapov_reporting@1.0.0 14:23:00 npm info ok 

我已经尝试在永远监视器中包装我的start.js脚本,但是这似乎没有任何区别。

UPDATE

我的ECS任务定义 –

 { "requiresAttributes": [ { "value": null, "name": "com.amazonaws.ecs.capability.ecr-auth", "targetId": null, "targetType": null }, { "value": null, "name": "com.amazonaws.ecs.capability.logging-driver.awslogs", "targetId": null, "targetType": null }, { "value": null, "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19", "targetId": null, "targetType": null } ], "taskDefinitionArn": "arn:aws:ecs:us-east-1:562155596068:task-definition/node:12", "networkMode": "bridge", "status": "ACTIVE", "revision": 12, "taskRoleArn": null, "containerDefinitions": [ { "volumesFrom": [], "memory": 128, "extraHosts": null, "dnsServers": null, "disableNetworking": null, "dnsSearchDomains": null, "portMappings": [ { "hostPort": 0, "containerPort": 3000, "protocol": "tcp" } ], "hostname": null, "essential": true, "entryPoint": null, "mountPoints": [], "name": "node", "ulimits": null, "dockerSecurityOptions": null, "environment": [ { "name": "awslogs-group", "value": "node_logs" }, { "name": "awslogs-region", "value": "us-east-1" }, { "name": "NODE_ENV", "value": "production" } ], "links": null, "workingDirectory": null, "readonlyRootFilesystem": null, "image": "562155596068.dkr.ecr.us-east-1.amazonaws.com/node:06b5a3700df163c8563865c2f23947c2685edd7b", "command": null, "user": null, "dockerLabels": null, "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "node_logs", "awslogs-region": "us-east-1" } }, "cpu": 1, "privileged": null, "memoryReservation": null } ], "placementConstraints": [], "volumes": [], "family": "node" } 

任务全部停止,状态为Task failed ELB health checks in (target-group ...启动失败之前传递2到3次,并且在日志中没有任何logging除了http 200以外的任何logging。

我正在使用老版本的mongo驱动程序〜2.0,并保持连接到一个以上的分贝。 当我升级司机时,问题就消失了。

  "dependencies": { "mongodb": ">=2.2" } 

我只能假设司机有一个错误。