AWS ECS:503服务暂时不可用

3
我已经部署了一个简单的Express服务器,用于对Angular 7应用程序进行SSR。它可以正常运行,但是一段时间后,请求会导致503服务暂时不可用响应。
我的服务中的事件选项卡显示我的任务正在排空和重启,但没有其他异常情况。我在实例的ecs-agent日志中没有看到任何奇怪的东西,只有我的任务发送容器停止/启动事件。
从我的服务的事件选项卡:
af81a908-d0ae-4f8d-a19f-4f5723053c71
2019-03-26 13:15:28 -0700
service ui has started 1 tasks: task 61e77740-7b6a-4785-a5c8-9e7581a79745.
8bc7eb29-6a22-4af8-9994-57f2cfd7ad26
2019-03-26 13:14:55 -0700
service ui has begun draining connections on 1 tasks.
cb064206-0ed4-4b68-b528-957175a93196
2019-03-26 13:14:55 -0700
service ui deregistered 1 targets in target-group contrast-fm-target-group
398e8407-17fa-466e-a482-1840f7b9674c
2019-03-26 11:40:31 -0700
service ui has reached a steady state.

从我的实例上的ecs-agent日志中:

2019-03-26T20:41:02Z [INFO] Managed task [arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea]: sending task change event [arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea -> STOPPED, Known Sent: RUNNING, PullStartedAt: 2019-03-26 20:40:56.5934327 +0000 UTC m=+24378.048113509, PullStoppedAt: 2019-03-26 20:40:56.769284895 +0000 UTC m=+24378.223965695, ExecutionStoppedAt: 2019-03-26 20:41:02.41672748 +0000 UTC m=+24383.871408417]
2019-03-26T20:41:02Z [INFO] TaskHandler: batching container event: arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea contrast-ui -> STOPPED, Exit 1, , Ports [{3000 80 0.0.0.0 0}], Known Sent: RUNNING
2019-03-26T20:41:02Z [INFO] TaskHandler: Adding event: TaskChange: [arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea -> STOPPED, Known Sent: RUNNING, PullStartedAt: 2019-03-26 20:40:56.5934327 +0000 UTC m=+24378.048113509, PullStoppedAt: 2019-03-26 20:40:56.769284895 +0000UTC m=+24378.223965695, ExecutionStoppedAt: 2019-03-26 20:41:02.41672748 +0000 UTC m=+24383.871408417, arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea contrast-ui -> STOPPED, Exit 1, , Ports [{3000 80 0.0.0.0 0}], Known Sent: RUNNING] sent: false
2019-03-26T20:41:02Z [INFO] TaskHandler: Sending task change: TaskChange: [arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea -> STOPPED, Known Sent: RUNNING, PullStartedAt: 2019-03-26 20:40:56.5934327 +0000 UTC m=+24378.048113509, PullStoppedAt: 2019-03-26 20:40:56.769284895 +0000 UTC m=+24378.223965695, ExecutionStoppedAt: 2019-03-26 20:41:02.41672748 +0000 UTC m=+24383.871408417, arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea contrast-ui -> STOPPED, Exit 1, , Ports [{3000 80 0.0.0.0 0}], Known Sent: RUNNING] sent: false
2019-03-26T20:41:02Z [INFO] Managed task [arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea]: sent task change event [arn:aws:ecs:us-west-2:584648718741:task/13cfb2bc-d40a-4c5b-be47-f73dc2ed28ea -> STOPPED, Known Sent: RUNNING, PullStartedAt: 2019-03-26 20:40:56.5934327 +0000 UTC m=+24378.048113509, PullStoppedAt: 2019-03-26 20:40:56.769284895 +0000 UTC m=+24378.223965695, ExecutionStoppedAt: 2019-03-26 20:41:02.41672748 +0000 UTC m=+24383.871408417]
2019-03-26T20:41:02Z [WARN] DockerGoClient: Unable to decode stats for container d999c0b9afba34f3e7e77e5d34a29c64edb931b1fbc99f53ccfe403c4490db9f: context canceled
2019-03-26T20:41:02Z [INFO] Container d999c0b9afba34f3e7e77e5d34a29c64edb931b1fbc99f53ccfe403c4490db9f is terminal, stopping stats collection
2019-03-26T20:41:04Z [INFO] Saving state! module="statemanager"

嘿,你有检查过任务日志或任务状态吗?有时候在任务屏幕(控制台)中可以获得更多信息,解释为什么容器处于STOPPED状态。看起来ALB无法访问容器,这就是为什么它们会被重启的原因。这些容器是否曾经到达过ALB目标组中的InService状态? - marianogg9
1个回答

0

看起来,由于某种原因,您的应用程序负载均衡器没有响应ECS健康检查调用。

检查一下您的目标组配置是否正确指向返回HTTP 200的路由。此外,请检查您的服务的安全组是否未阻止应用程序运行的端口的流量。

更多信息请参见此处


1
谢谢您的回复!我已经检查了我的目标群配置,它指向首页,返回“200”。我的服务的安全组也没有阻止来自应用程序正在运行的端口的流量。 - Ben Inada

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接