检测脚本何时延迟,并允许其在PHP中跳过或继续 [英] Detect when a script delays and allow it to skip or continue in PHP

查看:79
本文介绍了检测脚本何时延迟,并允许其在PHP中跳过或继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件,例如file1.php,该脚本内的脚本使用以下命令执行文件: exec( php-cli -f _DAEMON.php)之后执行 exec()命令,它需要运行更多代码,问题在于 _DAEMON.php 作为其名称表示,它是一个守护程序,它将永远不会停止运行,因此它将冻结file1.php,而不会允许其余代码运行。

I have a file, lets say file1.php, that within the script executes a file using: exec("php-cli -f _DAEMON.php") after executing the exec() command, it needs to run more code, the problem is that _DAEMON.php as its name says, is a Daemon and it will never stop running, so it freezes file1.php without allowing the rest of the code to run.

有没有一种方法可以允许即使 exec( php-cli -f _DAEMON.php)仍未完成的情况下,代码仍继续执行。还是要检测代码延迟是否超过x秒/毫秒,是否要继续?

Is there a way to allow the code to continue executing even if exec("php-cli -f _DAEMON.php") has not finished. Or to detect if the code delays for more than x seconds/milliseconds, to continue?

谢谢。

推荐答案

也许尝试使用套接字(curl可能会以较低的超时时间起作用,不确定它是否会立即杀死脚本)。不理想,会增加一些开销。

Maybe try using a socket (curl might work with a low timeout, not sure if it'll kill the script though offhand). Not ideal, will add some overhead.

http:// phplens .com / phpeverywhere /?q = node / view / 254

此外,doriana_gd可能引用了诸如node.js,服务器端javascript之类的东西

Also, doriana_gd was probably referring to something like node.js, server side javascript

这篇关于检测脚本何时延迟,并允许其在PHP中跳过或继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆