geopython / GeoHealthCheck

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

Partial fix for #372: faster shutdown of ghc_web Docker container #376

Closed fsteggink closed 3 years ago

fsteggink commented 3 years ago

This PR only prepends exec before the gunicorn command, resulting in the ghc_web Docker container being shut down much faster. No solution for the ghc_runner container though. Putting exec before the paver command doesn't have any affect, and neither has using exec somewhere inside runner_daemon in pavement.sh.

justb4 commented 3 years ago

I think the Runner needs a different approach. Although Paver is called, the Runner is in fact a regular Python program with a main() started in the module scheduler.py (runner.py would have been better name). The scheduler basically uses the PyPi library apscheduler for per-Resource scheduling. Regular Python signal handling could do the trick, though a slight difference when the Runner runs in the webapp. See e.g.

https://stackoverflow.com/questions/24520969/apscheduler-will-not-stop, the answer at the bottom, something like:

Out of my head:

import signal
.
.

def catch_signal(signum, frame):
    LOGGER.info('Stopping Scheduler on signal {}'.format(signum))
    stop_schedule()

signal.signal(signal.SIGINT, catch_signal)
signal.signal(signal.SIGTERM, catch_signal)

might do it stop_schedule() is within scheduler module.

justb4 commented 3 years ago

Ok, thanks @fsteggink !