Re: asynchronous launch of a script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 June 2011 03:42, Tamara Temple <tamouse.lists@xxxxxxxxx> wrote:
> How do I launch a php script from another running php script asynchronously?

I'm a windows user. One of the things I wanted to to was to create
non-blocking process which I could communicate with using PHP.

I use pecl/wincache to allow me to read/write data (can't use the
pipes as these are blocking and no support for non-blocking).
I also use ...

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run(...);

To create a new instance of a non blocking PHP script.

By using ...

$appID = ini_get('wincache.setappid');

I can supply do something like this ...

$s_Task = "C:\\PHP5\\php.exe -d wincache.setappid={$appID} -f " ....

to set the appid for the new instance, so it can communicate with this
instance via wincache.

All because there is no IPC in php for windows natively.

And it works for me really well.

I use pecl/win32service to create slow/long running tasks which have a
task controller controlling the work load.

I think I've re-invented a form of gearman in this work, but it works for me.


If you are on Windows and just want to get a script to run and really
don't care about when/how it ends, then

$WshShell = new COM("WScript.Shell");
$WshShell->Run("C:\\PHP5\\php-win.exe -f C:\\Scripts\\script.php", 0, false);

This will create an invisible non-blocking "thread" and return
immediately upon creating the "thread".


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux