Hey again,
Good point.
I've simplified this all into two small scripts.
If anyone is interested in the solution, contact me off
list and I'll send the source.
I will have an additional sanity/mantience script that ensures no
job runs longer than a given threshold.
Thanks for the help.
- Ben
----- Original Message -----
From: "Dan Cech" <[EMAIL PROTECTED]>
To: "NYPHP Talk" <talk@lists.nyphp.org>
Sent: Thursday, April 19, 2007 3:50 PM
Subject: Re: [nyphp-talk] IPC Problems
Ben Sgro (ProjectSkyline) wrote:
Hi All,
I'm trying to write a script, that forks children to each run a job,
provided by
the parent in the form of a job_id, passed by IPC msg_send( ).
Now, when I run the job, I get some problems w/the DB loosing the
connection.
I also have problems w/the job_id that's get passed ..sometimes, somehow,
its the
PID...I dont get it.
It seems like the IPC is all over the place ... I've included the output
from the script,
the database tables, and the source of the script.
Any help is greatly appreaciated. I've read the php.net pcntl_and msg-
(IPC) stuff over and over.
It sounds like you might be making this more complicated than it needs
to be.
What the goal is:
1) Parent, selects the next job to run.
2) Marks job as active =1, stores the PID
3) Forks off a child to run this (job_id passed to child via msg_send( ))
The child can read the job_id from a variable set in the parent before
the fork, why not just do this?
4) Child runs, finishes job and marks as active = 0, incremenents run
count, tells parent to kill them
Why does the child need the parent to kill them? A call to exit() at
the end of the child section should do the trick just fine.
5) Rinse lather repeat
Hope this helps,
Dan
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php