开发者

PHP / Apache - Refreshing screen while exec'd script is running

One page on my web site is a PHP script that uses exec() to launch a separate PHP script which generates a PDF document.

The PDF may take 30 seconds to generate. When I hit the refresh button during this process, I am finding inconsistent behavior. On both my Mac and Windows local dev machines, refreshin开发者_StackOverflowg the page will hang Apache. On my production Linux server, I don't seem to experience the problem.

Why is this? I don't care that my dev machines hang, I just want to be sure that it won't ever happen in production.


Do you run exec() every time the page is rendered, or do you have some logic to check whether the previous php script has finished?

You may be generating a new PDF every time you refresh the page. If this takes a while, it might be hanging Apache because all the threads in its thread-pool are waiting for the exec'ed scripts to finish, if they're not detached properly.

If that is the case, it could certainly hang Apache on your production server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜