I have an nginx web server to which I execute an nginx -s quit
. This is supposed to be a graceful shutdown, so its supposed to wait for all its connections to finish before shutting down.
To test to make sure that it is doing as advertised, I execute a curl on a 10M file served by nginx with --rate-limit=1024K
(per second), giving me 10 seconds to execute an nginx -s quit
before the download finishes. I would expect nginx to finish the download and then shut down, but every time I do this in the beginning of the download, nginx quits anyway and curl says:
curl: (18) transfer closed with 2019456 bytes remaining to read
Why would nginx shut down anyway? I couldn't find any documentation that says "Nginx waits for all connections to complete except..." My only theory is that with a rate limit, curl waits for such a long time in between sending packets that nginx thinks that the connection is stale... or something.
What am I doing wrong or misunderstanding?
EDIT:
I have done the same test on my local machine and everything worked correctly, so this is no longer a question about nginx. The environment in which the signal does not work correctly is google's kubernetes container cluster manager, where nginx is running. The nginx -s quit
is executed as a pre-stop hook, but it also fails when I exec into the docker container and run the quit command on the command line during the download. Note: my successful local machine test was done with nginx running inside a docker container, so it's NOT docker.