rtyler / Spawning

Spawning is a wsgi server which supports multiple processes, multiple threads, green threads, non-blocking HTTP io, and automatic graceful upgrading of code
http://pypi.python.org/pypi/Spawning
MIT License
120 stars 18 forks source link

Daemonizing before SIGHUP handler is installed. #33

Open nicholasknight opened 11 years ago

nicholasknight commented 11 years ago

I just spent an hour trying to figure out why an automatic deployment process was failing intermittently on certain servers, when I finally realized what was going on.

Spawning is daemonizing in spawning_controller.py:main(), starting around line 402, before eventually calling start_controller(), which calls Controller.run(), which in turn, finally calls signal.signal(signal.SIGHUP, self.handle_sighup).

Thus, if a controlling terminal goes away too fast after spawning forks into the background, spawning gets SIGHUP before the handler is installed, and dies.

This should be pretty easy to reproduce by doing something like:

ssh -t user@host "spawning etc.etc."