Reputation: 1527
I have an AWS service running loads of containers. I was wondering if its possible to make a python script that checks for the container health.
I know i can run commands for healthcheck so in theory i could run a python script that exits sys.exit(0)
or 1 depending on the healthcheck, does that makes sense?
Would it be possible to make a python script for a healthcheck? Would I need just to call the script on the healthcheck task?
Thanks for any info!
Upvotes: 4
Views: 2641
Reputation: 1
The following works for me
[ "CMD-SHELL", "python -c \"import sys; sys.exit(0)\"" ]
Upvotes: 0
Reputation: 6235
You will need to create your custom ECS Health check command using python and execute it via Shell. Below example has curl command running within container, you will need to run your python script instead of curl script.
[ "CMD-SHELL", "curl -f http://localhost/ || exit 1" ]
https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_HealthCheck.html
You need to make sure your python script return 0 part of successful execution. If you have tried something like with python then please share the details around difficulties you had.
Upvotes: 4