怎么做,如果我有几分钟运行CGI输出数据前,和Apache时候出来? [英] What to do if I have a CGI that runs for several minutes before outputting data, and Apache times it out?

查看:342
本文介绍了怎么做,如果我有几分钟运行CGI输出数据前,和Apache时候出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CGI脚本,需要很长的时间来执行。长话短说,它需要处理大量的数据,运行一堆缓慢的命令,并提出一些缓慢的网络查询,在这期间不输出任何东西,当它这样做,它终于打印其结果列于JSON格式。这需要几分钟的时间来运行,这是比在我的Apache Web服务器的httpd.conf设置超时指令更长。

I have a CGI script that takes a really long time to execute. Long story short, it needs to process a lot of data, run a bunch of slow commands, and make some slow web queries, during which time it doesn't output anything, and when it's done, it finally prints its results out in JSON format. It takes several minutes to run, which is longer than the Timeout directive set in my Apache web server's httpd.conf.

我不能随意在全球范围内改变超时值对每个人都是整个服务器上。我想,也许的覆盖,在使用.htaccess文件每个目录的基础,但它看起来像超时指令不在.htaccess上下文,所以不能做。据我所知,我的脚本必须不断输出数据,而如果它的秒超时数不输出数据,阿帕奇放弃。

I am not at liberty to change that Timeout value globally for everyone on the entire server. I thought of maybe overriding that in a per-directory basis using a .htaccess file, but it looks like the Timeout directive is not in .htaccess context, so that cannot be done. From what I understand, my script must continually output data, and if it doesn't output data for the Timeout number of seconds, Apache gives up.

我收到以下错误阿帕奇:(70007)指定的超时时间已过期:ap_content_length_filter:apr_bucket_read()失败

I am getting the following error in Apache: (70007)The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed

我该怎么办?

推荐答案

我想出了一个解决方案。

I came up with a solution.

我就开始输出一个虚拟HTTP头,如假:... ,我可以把我想要的任何数据作为头的值,它不会告发'T影响输出的其余部分。所以我会输出一个字符到每分钟左右,$ P $超时pventing它是虚值。而当我准备好了,我可以打印一行返回并继续打印我的(真正)的HTTP标头的其余部分,该文件的内容。

I would start outputting a dummy HTTP header, like Dummy: ..., and I can put whatever data I want as the value of that header, and it wouldn't affect the rest of the output. So I would output a character to that dummy value every minute or so, preventing it from timing out. And when I am ready, I can print a line return and continue printing the rest of my (real) HTTP headers and the content of the document.

这篇关于怎么做,如果我有几分钟运行CGI输出数据前,和Apache时候出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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