python – 优雅地停止ecs容器

我有一些docker容器,它监听RabbitMQ并处理收到的消息.我有一个代码管道,它启动图像的重建并在有代码提交时更新任务.

我的问题是容器将在消息处理期间突然被杀死有任何方式我可以停止容器查杀,直到过程完成并允许它停止,以便新的新容器将自动创建,因为我没关系当前容器使用旧代码处理消息.我的容器正在里面运行python代码.

谢谢

解决方法:

ECS by default sends a SIGTERM

StopTask

Stops a running task.

When StopTask is called on a task, the equivalent of docker stop is
issued to the containers running in the task. This results in a
SIGTERM and a default 30-second timeout, after which SIGKILL is sent
and the containers are forcibly stopped. If the container handles the
SIGTERM gracefully and exits within 30 seconds from receiving it, no
SIGKILL is sent.

Note

The default 30-second timeout can be configured on the Amazon ECS
container agent with the ECS_CONTAINER_STOP_TIMEOUT variable. For more
information, see Amazon ECS Container Agent Configuration in the
Amazon Elastic Container Service Developer Guide.

了解这一点,您可以在应用程序中添加一个简单的检查以捕获SIGTERM,并做出适当的反应.

相关文章

Docker是什么Docker是 Docker.Inc 公司开源的一个基于 LXC技...
本文为原创,原始地址为:http://www.cnblogs.com/fengzheng...
镜像操作列出镜像:$ sudo docker imagesREPOSITORY TAG IMA...
本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p...
在 Docker 中,如果你修改了一个容器的内容并希望将这些更改...
在Docker中,--privileged 参数给予容器内的进程几乎相同的权...