Thanks Rocco, that effectively answers my original header (which I forgot to
change), via your example:

do_thing => $start_or_stop, $next_time, $period, $program, $args

I've been rethinking how to do this, problem is I'm not sure the best way to
leverage POE.

Currently, I have this POE server that periodically gets a stock quote from
ameritrade's real time quotes (via www:mechanize).  Then my POE client gets
the quote from the POE server.  The problem is after a few hours the server
dies (because for some unknown reason ameritrade give me a 500 internal
server error).

I figured I'd build a POE server to periodically stop and start my POE quote
server.

Jay

----- Original Message -----
From: "Rocco Caputo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 12, 2003 3:16 PM
Subject: Re: Passing parms to delayed sessions


> On Fri, Sep 12, 2003 at 08:51:46AM -0500, Jay Strauss wrote:
> > Hi,
> >
> > I'm trying to build a pgm that will launch and stop a bunch of my
programs
> > on some schedule.  Sorta like cron, but all I'd have to do is start this
one
> > program and it would do all the work of starting and stopping the rest
of
> > the programs.  Maybe you could call it a job parent.
> >
> > I need to stop then immediately start one of the programs every hour.
So in
> > effect, this parent job is kind of like a janitor stopping and starting
this
> > other program once and hour.
>
> So far you can do this through cron without running a second management
> program.  If your program drops a PID file somewhere, it can be used as
> a handle to stop and start it.
>
>   #!/bin/sh
>   /bin/kill -HUP `/bin/cat /var/run/thingy.pid`
>   sleep 1
>   /usr/local/bin/thingy
>
> That would run nicely out of cron.
>
> > I figure I will have other child programs that need to be started and
> > stopped on their own schedule.
> >
> > The only way I can think of doing it with POE, is by having a inline
state
> > for each start and stop of each child program, so that I can schedule
them
> > independently.  Seems very inflexible.  I was hoping someone could point
me
> > in a better direction
>
> It would be better to load the schedule at once and set alarms for the
> next activity of each program.
>
>   while (<SCHEDULE>) {
>     chomp;
>     my ($period, $program, $args) = split;  # hypothetically
>     my ($start_or_stop, $next_time) = some_calculations($periord);
>     $kernel->alarm(do_thing => $start_or_stop, $next_time, $period,
$program, $args);
>   }
>
> The "start_thing" handler would pull off the parameters and start your
> program:
>
>   sub handle_start_thing {
>     my ($start_or_stop, $period, $program, $args) = @_[ARG0, $#_];
>
>     if ($start_or_stop eq "start") {
>       # ... start the program here ...
>     }
>     else {
>       # ... stop the program here ...
>     }
>
>     # Figure out what to do next.
>     my ($start_or_stop, $next_time) = some_calculations($period);
>     $kernel->alarm(do_thing => $start_or_stop, $next_time, $period,
$program, $args);
>   }
>
> Consider this pseudo-code.  It deliberately ignores a lot of details,
> like what some_calculations() does, or how you tell whether to start or
> stop a program.
>
> Good luck.
>
> --
> Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/
>
>
>

Reply via email to