On 2 dec 2006, at 22.13, Cat Dancer wrote:
I'd like to write a server accepting incoming network connections that can be gracefully shutdown.
When the server is asked to shutdown, it should stop accepting new connections, finish processing any current connections, and then terminate.
Clients can retry if they attempt to make a connection and the connection is refused. This allows the server to restart seamlessly: any existing connections are not interrupted, and clients will see at most a pause while the server restarts.
I am using the model from Simon Marlow's Haskell Web Server (as updated by Björn Bringert and available at http://www.cs.chalmers.se/~bringert/darcs/hws/): spawning a lightweight Haskell child thread for each client connection. ...
I'd just like to add that the main repository for the conservatively updated HWS is http://darcs.haskell.org/hws/ There is also a more aggressively updated version at http:// www.cs.chalmers.se/~bringert/darcs/hws-cgi/ It supports CGI programs, has a module system for extensibility (no dynamic module loading though), more flexible logging, support for listening on multiple sockets, and many other changes. Contributions to either of these are very welcome. /Björn