微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,并做出适当的反应.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐