1

I created a flask app that has an underlying peewee database. It also interacts with openstack to create vms. This app is served by waitress via a DOCKERFILE

>> Docker file
ENTRYPOINT ["/usr/src/app/wrapper.sh"]

>> In wrapper.sh
# Start the primary process and put it in the background
poetry run waitress-serve --port=5000 --threads=8 --call "server:app.create_app" &

When I re-run docker compose I believe that docker sends a SIGTERM and waits 10 seconds before SIGKILL. Does waitress try to complete requests currently being processed? Or is there a way to tell it to? I can add some handlers within the app itself but if I can get the behavior without having to add code to the underlying app... Thant would be ideal.

bison
  • 739
  • 5
  • 21
  • I think you are actually coming up against a Docker learning. If you are not using an init system (which you may not need!), you need to run your entrypoint with `exec` not by doing a `&`. If you do `&` it can become a "zombie process" and anyways it definitely does not respond to SIGTERM from the original process anymore. If you do `exec` then the launched process "becomes" the main process and SIGTERM etc still work. – floer32 May 09 '19 at 17:34
  • 1
    Note when I say `exec` I am referring to the shell/linux command, not to `docker exec` which just happens to have a similar name. For more info about `exec` take a look at [this StackOverflow thread explaining why `exec "$@"` is so often seen in Dockerfiles/`ENTRYPOINT`s](https://stackoverflow.com/a/48096779/884640). – floer32 May 09 '19 at 17:37

0 Answers0