Closed sonicnkt closed 2 years ago
We can do something similar to what geonode does
[uwsgi]
uwsgi-socket = 0.0.0.0:8000
http-socket = 0.0.0.0:8001
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8001/"
start_period: 60s
interval: 60s
timeout: 10s
retries: 10
Guess if running the additional socket isn't using any additional system resources this is fine.
In the
docker-compose.yml
a health for the django container is performed using a simple curl command inside in the container to check if the server is running:test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8000/"
But this isn't working anymore since in the default configuration an http-socket isn't configured, this results in curl exiting with code 52 as its getting an empty reply from the server.
This results in a permanent unhealthy status of the container and is misleading.
A solution would be to use uswgi_curl from the uwsi-tools package (pip). It does not offer the same options as curl but results in a correct exit code (0 working, 1 not working).