Closed edomora97 closed 2 years ago
What about adding curl, wget or httpie?
We can do that, I just tried to avoid adding another package to the container (especially for this simple task). But yeah, I will feel a bit safer if no PHP from me is present anywhere in the codebase 😂
Also there is an option since a few weeks to specify the path where domjudge is served from, we should take into account I think?
I didn't know about that, I'll check this immediately.
Also there is an option since a few weeks to specify the path where domjudge is served from, we should take into account I think?
I didn't know about that, I'll check this immediately.
Ok, I have two possible solutions for that:
$WEBAPP_BASEURL
inside the health check, but the value is the same provided to the container (the fixes done here are not present). So it is possible that something would break (even though I can't imagine why)/opt/domjudge/domserver/webapp/config/static.yaml
), which is written from hereI'm leaning towards option 2 to minimize the risk of doing something wrong or unexpected. What do you think?
The result would be something like:
BASEURL=$(grep domjudge.baseurl /opt/domjudge/domserver/webapp/config/static.yaml | awk '{ print $2 }')
if curl --silent --fail "$BASEURL/api" >/dev/null; then
printf "http ok"
else
printf "http error"
ret=1
fi
Second option sounds good. And regarding the package: I think curl or wget are so small it’s totally fine
I also pushed a new 7.3.4 image to Docker Hub
It looks good to me.
When running the Docker container for domserver, it is possible that one of nginx or php-fpm crashes/stops working. When this happens from outside the container the effects can be quite mysterious. Adding an health check allows the user to diagnose more quickly what happened.
Running
docker ps
, in the columnSTATUS
it is shown:Up X minutes (healthy)
orUp X minutes (unhealthy)
depending on the exit code of the health check script. To further diagnose the problem one can rundocker inspect domserver
(optionally piped tojq '.[0].State.Health'
) and this will report diagnostic information like:This health check probes supervisord for the status of the two services (nginx and php-fpm), as well as tries to reach the API with an HTTP request. To perform this HTTP request I've used
php -r
since in the image there isn't curl nor wget. My PHP skills are crap, I won't be surprised if there's a better way to do that.This commit also fixes the deprecated
MAINTAINER
labels in the various Dockerfiles.Some context: we were running DJ in the docker container while suddenly the server switched off (probably due to a power loss). When it got back on the docker container restarted automatically but php-fpm failed to start logging:
From the outside the result was a 502 from "nginx", but from which nginx was not clear since we also had nginx running outside docker. And we were a bit confused by the fact that the container was still running fine (or at least we initially thought). We could diagnose the problem much more quickly if
docker ps
showed us that the container was not healthy. Why php-fpm couldn't start automatically is still a mystery to me, since that file (at the moment at least) does not exist. I'll try to further investigate this later.