I have some dynamic spawning of workers in a supervision tree going on in http://github.com/noss/iserve. The iserve application has a master registered process that i call iserve_master
it is supervised together with a simple one for one mode supervisor.
The iserve_master
is for asking iserve to start a http server. It can have multiple iservers, as long as they bind to unique addresses. The started servers construct a name for themself though, but that is to simplify debugging, it generates an atom using the port name.
A server is is an "eternal" loop waiting for a iserve_socket
to call back about having accepted a connection. It starts the first one in init.
The started socket is not under supervision because it is not able to restart without losing the http socket connection anyway. And I see it as a bit of a feature to not care. Fire and forget.
Its far from perfect, but an architecture that I somewhat like.