I am having some docker container which listens on RabbitMQ and process the message received. I have a code pipeline which kicks off the rebuilding of the image and updating the tasks when there is a code commit.
My problem here is the container will be killed abruptly during the message processing is there any way where I can stop the container killing until the process is finished and allow it to stop so that a new new container will be automatically created as I am ok with the current container processing the message with the old code. My container is running python code inside.
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.
Knowing this, you can add a simple check in your app to catch the SIGTERM, and react appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With