避免CGI超时

发布于 2024-09-27 13:49:36 字数 702 浏览 0 评论 0原文

我有一个函数,它获取一个大的 XML 文件,然后解析它,然后使用详细信息来获取更多 xml 文件,然后再次解析它们(网上商店)。

问题是,处理大约需要 15-20 分钟,但脚本在此之前超时,并向我发送了 500 错误消息。

有办法解决这个问题吗?

我在这里读到一篇文章,经常写一条日志消息有助于避免这个问题,但我该怎么做呢?如果我尝试回显、写入或返回某些内容,它只会返回值并结束我的函数。

以下是错误消息:

[Wed Oct 13 10:34:41 2010] [warn] [client 213.175.111.200] Timeout waiting for output from CGI script /home/virtual/site14/fst/var/www/interpreters/php-script
[Wed Oct 13 10:34:41 2010] [error] [client 213.175.111.200] Premature end of script headers: php-script
[Wed Oct 13 10:36:41 2010] [warn] [client 213.175.111.200] Timeout waiting for output from CGI script /home/virtual/site14/fst/var/www/interpreters/php-script

谢谢!

I have a function, that gets a large XML file, then parses it, and then uses the details, to get some more xml files, that are again parsed ( A webshop).

The problem is, that the processing takes about 15-20mins, but the script timeout's before that, and sends me a 500 error message.

Is there a way around this?

I read on a post here, that writing a log message every so often helps avoid this problem, but how do I do that? If I try to echo, write or return something, it just returns the value and ends my function.

Here are the error messages:

[Wed Oct 13 10:34:41 2010] [warn] [client 213.175.111.200] Timeout waiting for output from CGI script /home/virtual/site14/fst/var/www/interpreters/php-script
[Wed Oct 13 10:34:41 2010] [error] [client 213.175.111.200] Premature end of script headers: php-script
[Wed Oct 13 10:36:41 2010] [warn] [client 213.175.111.200] Timeout waiting for output from CGI script /home/virtual/site14/fst/var/www/interpreters/php-script

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何时共饮酒 2024-10-04 13:49:36

对于那些寻找答案的人来说,您可以找到一些似乎有效的方法:

  1. 将 Web 服务器上的 TimeOut 值设置为 0 或相当大的值。我最终将其设置为 0,因为我需要我的脚本永远运行。
  2. 如果由于使用共享主机而无法实现 1,您最可能的选择是定期返回一些日志信息。我确实必须警告您不要将此代码放入函数中,因为不可能持续不断地返回函数。您可以将代码的一部分设为函数,但最终,好的旧 echo 函数将为您完成
  3. 您可以尝试一些 Comet 方法,但它们相当复杂,而且很可能不会解决每一个问题。

PS 我使用 javascript 重定向在某种程度上解决了我的问题,这是一个痛苦的问题,所以我不建议任何人以同样的方式这样做。

For those looking for an answer, there are a couple of things you could find, that seem to work:

  1. Setting the TimeOut value on your Web server to 0 or something quite big. I ended up setting it to 0, since I needed my script to run , like, forever.
  2. If 1 is not possible due to using shared hosting, Your most likely option is to return some log information periodically. I do have to warn you not to make this code into a function, since it is not possible to keep returning a function continuously. You can make a part of the code a function, but in the end, the Good old echo function will do it for you
  3. You can try some Comet approaches, but they are fairly complex, and most probably wont solve every problem.

P.S. I somewhat got around my problem using javascript redirects, which were a pain in the a*s, so I do not recommend anyone doing it the same way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文