Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plone-backend image is not responding correctly to SIGTERM #130

Open
fredvd opened this issue Nov 1, 2023 · 5 comments
Open

plone-backend image is not responding correctly to SIGTERM #130

fredvd opened this issue Nov 1, 2023 · 5 comments
Assignees

Comments

@fredvd
Copy link
Sponsor Member

fredvd commented Nov 1, 2023

While testing the cookiecutter-plone-starter docker compose setup today I noticed that when I stop the compose setup, the backend container takes 10-11 seconds to stop. This is the 10 second timeout when the application in side the container doesn't respond correclty to the 'nice' way of asking to stop (I think SIGTERM) and then a SIGKILL follows.

This might have to do something with our entrypoint script that starts the instancne and somewhere along the process chain the signals are not correctly passed along. Any takers? ;-)

@avoinea
Copy link
Sponsor Member

avoinea commented Nov 3, 2023

I'm not sure I can reproduce this one:

$ docker run --name plone -it --rm -p 8080:8080 -e SITE=Plone plone/plone-backend

docker top should give you the insights

 docker top plone 
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
500                 401333              401311              28                  14:29               pts/0               00:00:04            /app/bin/python /app/bin/runwsgi -v etc/zope.ini config_file=zope.conf

Installing htop in container also shows runwsgi as PID 1 👍

Screenshot from 2023-11-03 14-32-37

Doing exec CMD should usually be enough https://github.com/plone/plone-backend/blob/6.0.x/skeleton/docker-entrypoint.sh#L147

@fredvd
Copy link
Sponsor Member Author

fredvd commented Nov 3, 2023

@avoinea Thanks for checking. I was uncertain if I should post it here on plone-backend or if it maybe was a docker compose specific issue. But I can also reproduce it with the 'pure' plone-backend image .

If you run the container with:

$ docker run -d --name plone -it --rm -p 8080:8080 -e SITE=Plone plone/plone-backend

so it is started in the background. And when you then stop the container with

$ docker stop plone

[ 10 - 11 seconds]

$

You will see it takes 10-11 seconds before the container is really stopped.

Maybe when running the docker container in the foreground with stdout connected/redirected to the terminal session, the ctrl-c is passed on different and the container stops immediately. But running it detached, in compose or probably in a stack the signal is not coming through correctly.

@davisagli
Copy link
Sponsor Member

I think the signal is getting passed to the application fine but waitress doesn't have any support for a graceful shutdown using SIGTERM. See Pylons/waitress#198

Ctrl+C works because it sends SIGINT, not SIGTERM.

@davisagli
Copy link
Sponsor Member

As a workaround we could probably put STOPSIGNAL SIGINT in the Dockerfile.

But both that solution and the status quo have the downside of interrupting in-flight requests. It would be nice to use a WSGI server that supports graceful shutdown.

@Rudd-O
Copy link
Contributor

Rudd-O commented Nov 20, 2023

Graceful shutdown is a must, seconding that request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants