geopython / GeoHealthCheck

Service Status and QoS Checker for OGC Web Services
https://geohealthcheck.org
MIT License
84 stars 71 forks source link

Docker-compose down takes 10 seconds #372

Open fsteggink opened 3 years ago

fsteggink commented 3 years ago

When using GHC with Docker I've noticed that the command docker-compose down takes about 10 seconds. This is an indication that the containers are removed forcefully by Docker. Probably the termination signal sent by Docker is not captured properly, which results in an unclean shutdown.

justb4 commented 3 years ago

Looks like this question on StackOverflow. Related to gunicorn. Other sources also suggest to use CMD exec .... But gunicorn itself may also react on HUP signals in later versions: https://docs.gunicorn.org/en/stable/signals.html .

fsteggink commented 3 years ago

Yes, that is definitely the case. I'd use a trap for the TERM signal though, since that is what Docker sends (in my experience). In my own containers I've used signal handlers for the TERM signal and they work well.

fsteggink commented 3 years ago

So, for ghc_web it might be as simple as prepending exec to the gunicorn command in run-web.sh. However, the runner calls a paver command (see run-runner.sh), but it's worth a try.

fsteggink commented 3 years ago

I can confirm that prepending exec for the gunicorn command works. The ghc_web command is shut down after a few seconds. However, the ghc_runner command still needs 10 seconds to shut down, although I'm using exec paver now.

fsteggink commented 3 years ago

From the Gitter chat: I've noticed that when starting the runnerwithin the web app, multiple schedulers are started. This is because Gunicorn starts multiple workers. That might lead to potential conflicts (like same check executed simultaneously). Luckily the number of workers can be reduced by setting WSGI_WORKERS=1.

I'll submit a PR as a partial fix for this issue.

fsteggink commented 3 years ago

The correct PR for the partial fix is #376.