Mongrel2 Graceful Shutdown, Murderous Death, and Reloading
- From:
- Zed A. Shaw
- Date:
- 2010-07-22 @ 08:12
Alright everyone, it's *very* early, but took me a couple days of
messing with the internals of the tasks to figure out how to get
soft-reloading to work and graceful shutdown. It works, although
probably not reliably under load. Should be good enough for development
cycles though and will improve as time goes on.
If you want to try it, here's what you do:
Get the code and reinstall again. It still tries to install python
first but you should know how to fix that if that's broken for you.
Now you can do a simple start in one window:
m2sh start -db tests/config.sqlite -host localhost
Start another window and give it a stop:
m2sh stop -db tests/config.sqlite -host localhost
It should do the shutdown and tell you how many things its waiting for
before really exiting.
If you want to play with murder then try starting the server, then
telnet to port 6767 and leave it up. Then do a m2sh stop and you'll see
it wait for that telnet connection to die.
Since it won't die because you have it open, you can murder it with:
m2sh stop -db tests/config.sqlite -host localhost -murder
And it'll get the TERM signal and exit immediately.
Reloading works the same way, start a server in one window then do this:
m2sh reload -db tests/config.sqlite -host localhost
Because of how reloading works you have to hit it with at least one
request:
curl http://localhost:6767/tests/sample.json
You should get that request back, and then see the server reload the
config and go back to serving requests again.
Alright, that's it so far, play with it and find bugs so I can fix them.
This code is cleaned up but still doing some nasty things to the
internals to make it all work.
--
Zed A. Shaw
http://zedshaw.com/