Detect when a script delays and allow it to skip or continue in PHP

元气小坏坏 提交于 2019-12-25 14:10:36

问题


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.

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?

Thanks.


回答1:


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

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



来源:https://stackoverflow.com/questions/17500071/detect-when-a-script-delays-and-allow-it-to-skip-or-continue-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!