[Flask] Detecting when the server dies
Marc Branchaud
marcnarc at xiplink.com
Wed Jul 15 17:25:39 EDT 2020
Hi all,
I run flask under lighttpd with flup for FCGI. This runs on a single
machine, and I've configured lighttpd to launch the FCGI processes
itself, rather than have them live independently.
One of the things I use flask for is to invoke an old CGI binary and
send its output to the browser. The CGI subprocess is simply linked to
the Response with direct_passthrough=True.
Occasionally something causes lighttpd to crash. When that happens, the
system automatically restarts lighttpd so that the web service stays up.
Thing is, the crashed lighttpd's flask children get zombie'd to the init
process, and they never die. If the CGI is running when this happens.
the subprocess buffer fills up, then everything blocks.
Unfortunately the old CGI binary does some coarse-grained locking, and
so later invocations of that binary (under the new lighttpd process)
block waiting for the zombie-child instance to exit.
I agree that there's a lot weird about this setup, but I'd like to focus
on why the flask children don't see that the lighttpd socket has closed.
I would expect them to see that the socket they're writing to has
closed prematurely, and deal with that (or at least crash).
I'm not even sure where to look to start figuring this out. Somewhere
in Werkzeug, perhaps?
Any insights would be most appreciated!
M.
More information about the Flask
mailing list