[nycphp-talk] WAMP (minus the M) forking question - also open to other ideas
John Campbell
jcampbell1 at gmail.com
Tue Apr 28 00:42:08 EDT 2009
A quick google search for "windows run process in background" yielded:
"In case anyone has this problem in future, I finally found out the
solution. The START command in Windows command line allows you to
start another command window running any command; and the /B option
can start the command without the extra command window, so you get
similar behavior to Unix's background processes. Look it up for more
details."
I don't use windows, but I trigger background processes with and "&"
in *nix, and it looks like windows offers the same functionality with
"start /b"
regards,
John Campbell
On Tue, Apr 28, 2009 at 12:16 AM, Michael J. Forte
<michaelforte at hotmail.com> 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
> Software Engineer, IBM
>
> Education: Clarkson University Alum (2005) :: Resume
> E-mail: 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
>
More information about the talk
mailing list