gpt4 book ai didi

PHP 在后台进程完成后启动脚本?

转载 作者:可可西里 更新时间:2023-10-31 23:44:24 26 4
gpt4 key购买 nike

我正在使用 PDF2SWF 转换 PDF 并使用 XPDF 建立索引.. 使用 exec.. 只是这需要非常长的执行时间。

是否可以将其作为后台进程运行,然后在完成转换后启动脚本?

最佳答案

一般情况下,php是没有实现线程的。

但是有一个 ZF 级可能适合你:

http://framework.zend.com/manual/en/zendx.console.process.unix.overview.html

ZendX_Console_Process_Unix allows developers to spawn an object as a new process, and so do multiple tasks in parallel on console environments. Through its specific nature, it is only working on nix based systems like Linux, Solaris, Mac/OSx and such. Additionally, the shmop_, pcntl_* and posix_* modules are required for this component to run. If one of the requirements is not met, it will throw an exception after instantiating the component.

合适的例子:

class MyProcess extends ZendX_Console_Process_Unix
{
protected function _run()
{
// doing pdf and flash stuff
}
}

$process1 = new MyProcess();
$process1->start();

while ($process1->isRunning()) {

sleep(1);

}

echo 'Process completed';

.

关于PHP 在后台进程完成后启动脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2414498/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com