← Back to team overview

launchpad-dev team mailing list archive

Re: Proof-of-concept 'forking' lp-serve

 

On 18 August 2010 11:06, John Arbash Meinel <john@xxxxxxxxxxxxxxxxx> wrote:
> launchpad codehosting is a twisted daemon (I don't know exactly how it
> gets started). Somehow we will also start the 'lp-service' daemon.
> Either from the Conch ssh daemon, or via the 'make run' sort of scripts.
>
> Once running, the ssh daemon will make a request to the lp-service for
> it to fork itself, and reply with a message about where to find the
> named pipes that the new process will communicate. (As opposed to just
> using stdin/stderr/stdout of a Popen() process.)
>
> The way it is written, the lp-service daemon periodically polls its
> forked children to clean up any zombies, etc. It will also delete any
> named pipes that are still on the filesystem in case a child process
> dies without cleaning itself up. (If you request a fork, but never
> connect, that child hangs indefinitely trying to open the pipe.
> Potentially we want to send SIGINT, or something to the children.)
>
> Anyway, *if* we start lp-service from Conch, then the per-request
> processes would be grand-children of Conch. (But I don't think 'os.wait'
> will notice them.) If we start the service as a normal daemon, it would
> end up as a child of 'init' most likely, and then there would certainly
> be no direct relationship between the per-request processes, and the
> Conch daemon.
>
> I don't know that it matters. Presumably a client that connects will
> send information to the 'stdin' pipe, until the client is done. It may
> hold open the connection for a while, but eventually the client process
> will exit, and the connection will close, thus closing the stdin for the
> new connection, and presumably that will cause the lp-serve --inet to
> decide it is done and exit.

I think the 'lp-service daemon' (you must get a better name before
landing!) should just log when its children exit, and make sure that
it closes its copies of the file descriptor, so that they finally
close when the child exits.  Then conch can see that closure and pass
it onto the network.

It would be nice, since you're waiting on children, to also log their
resource usage.  wait4 should do this.

-- 
Martin



References