NYCPHP Meetup

NYPHP.org

[nycphp-talk] WAMP (minus the M) forking question - also open to other ideas

Rene Samson reneasaf at gmail.com
Wed Apr 29 10:02:51 EDT 2009


Michael,
I don't know how much control you have over the webserver, but have you 
looked at the PCNTL extension? I've played around with it a while ago, 
and it works very nicely. I've only used it in a LAMP environment, but 
it should do the same in a WAMP environment.
Rene

Michael J. Forte wrote:
> Hi experienced and talented community of which I have been trolling 
> for a few years!
>
> I have a question for all of you and I hope this makes sense.
>
> First, the background. I am coding a PHP Web application that has to 
> call a external program, however, because only one instance of the 
> program can be ran at a time I need to implement a queue. In addition, 
> it is important the users need to not wait (keep the browser open) for 
> their job to process. The script will send them an e-mail with a link 
> after their job completes. This means I need something to persistently 
> run whenever there is something in the queue. In summary: front end 
> script calls secondary child which runs until queue is empty by 
> calling external program.
>
> My problem is, I cannot figure out how to properly fork under Windows, 
> allowing the parent script to run to completion, and not hang the 
> browser waiting for the child to complete. I am at the point where I 
> can spawn the child and it will run even when the parent browser is 
> closed but will not release the parent script until it completes. I 
> have tried exec(), system(), shell_exec(), popen(), and a COM call 
> (which I might have done wrong). Each of those called php -f 
> childScript.php.
>
> I thought about a few other alternatives:
>
> 1. Use a scheduled task to check for a queue at a set interval. This 
> is the least desired solution as it could cause unwanted delay.
> 2. Write a PHP daemon/Win32 service to monitor a queue of which could 
> be queried and started if needed by parent script and it would run 
> until the queue is empty at which time it would shutdown.
> 3. Write a Perl script to be called by the parent which would fork and 
> call the secondary PHP script, subsequently terminating and releasing 
> the parent PHP script.
>
> In summary:
>
> - WAMP environment, cannot use Linux as external program is Windows 
> only (BUMMER!)
> - Need a queue to handle calls to an external program, currently 
> stored in a flat file
> - Parent script needs to fork to a child script which can run 
> independent of the parent until queue is empty
> - Parent script needs to be able to complete prior to child completing
> - Because of time required to run a job and because of the potential 
> for many users, users need to be able to submit'n'run.
>
> Do any of you PHP gods (and goddesses!) have any thoughts on how to 
> fork under Windows, how to handle this situation, or alternatives? 
> Should I be using some other language? Perl, AJAX, other?
>
> Google (or my search string) was less than helpful.
>
> -- 
> Thank you,
> Michael J. Forte
> Web Designer, WR Web Designs
> Webmaster, Town of LaFayette <http://www.townoflafayette.com>
> Software Engineer, IBM <http://www.ibm.com>
>
> Education: Clarkson University <http://www.clarkson.edu> Alum (2005) 
> :: Resume <http://www.within-reason.com/resume/Michael_Forte_resume.pdf>
> E-mail: michaelforte at hotmail.com <mailto:michaelforte at hotmail.com>
>
> "Often those who work the hardest are the luckiest..."
> ------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090429/511acbd6/attachment.html>


More information about the talk mailing list