On Thu, Jul 19, 2001 at 10:46:53AM -0400, Rocco Caputo wrote:
> On Thu, Jul 19, 2001 at 04:03:24PM +0200, Anton Berezin wrote:

> > What is the easiest way to achieve this goal, so that the master
> > process will only provide watchdog functionality?

> The easiest workaround I can see is to have the parent process create
> a listening socket (probably with IO::Socket::INET) and keep a copy of
> it in its HEAP.  Each child processe would immediately start a
> ListenAccept wheel on the saved socket as their first task.

Thanks.  That's basically the classical UNIX way of achieving this:
create(), bind(), and listen() in the parent, and call accept() in each
and every child.

What about preventing the master process from destroying itself?  Right
now I can only come up with:

In master's _start:

  $kernel->yield('sleeping_state');

   sub sleeping_state
   {
      ...
      $kernel->delay('sleeping_state', SOME_TIME);
   }

There should be some kind of canonical (for POE) way of just sitting
there doing nothing waiting for signals.

> Mind you, the child processes don't have to exit if they don't leak
> resources.  I modelled the idea after Apache, which recycled child
> processes now and then to prevent runaway daemons.

Yeah, sure.  They might die from time to time in a buggy program, though
- this is one reason to have a watchdog.  And the reason to have a
preforked server for me is that another truly asynchronous POE process
talks to this server, but the server needs to do blocking calls (DBI).
So in order to get a desired degree of concurrency I use pre-forking.
Strictly speaking, this server is probably easier to write without POE,
but since the rest of the application uses it this was a natural choice.

Thanks again for you help,
=Anton.
-- 
May the tuna salad be with you.

Reply via email to