2

我正在调试 Apache、Fast-CGI 和我们的 Perl 应用程序的问题。根本原因是如果执行了某个操作,Perl 应用程序需要退出并重新加载。在 CGI 下这不是问题,因为每个请求都会加载应用程序。

但是,它看到 Fast CGI 协议没有考虑这种情况——没有办法向 WebServer 发出信号你要退出——你只是退出。

但是这样做,我们在 mod_fastcgi 方面遇到了一个看起来像是竞争条件的情况:它识别出程序已退出,但随后尝试向它发送请求。最终它放弃并向浏览器返回错误 500。

我在网上看到类似的错误消息,但这些是关于 PHP 在 500 个请求后退出,解决方案是告诉 fastcgi 将每个进程的请求数限制为 500。这不适合我的问题,因为我需要在某些情况下退出请求而不是在固定数量的请求之后。

信息:Apache 模块加载:

LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so

两条日志行:服务器检测到应用程序退出,但随后尝试连接它

[Thu Jul 05 15:02:32 2012] [warn] FastCGI: (dynamic) server "/Users/sfomberg/Sites/cgi-bin/mt/mt.cgi" (pid 9277) terminated by calling exit with status '0'
[Thu Jul 05 15:02:32 2012] [warn] FastCGI: (dynamic) server "/Users/sfomberg/Sites/cgi-bin/mt/mt.cgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds

最后,放弃:

[Thu Jul 05 15:03:07 2012] [error] [client 127.0.0.1] FastCGI: comm with (dynamic) server "/Users/sfomberg/Sites/cgi-bin/mt/mt.cgi" aborted: (first read) idle timeout (30 sec), referer: http://localhost/~sfomberg/cgi-bin/mt/mt.cgi?__mode=cfg_plugins&blog_id=0&switched=1
[Thu Jul 05 15:03:07 2012] [error] [client 127.0.0.1] FastCGI: incomplete headers (0 bytes) received from server "/Users/sfomberg/Sites/cgi-bin/mt/mt.cgi", referer: http://localhost/~sfomberg/cgi-bin/mt/mt.cgi?__mode=cfg_plugins&blog_id=0&switched=1

我试图在结束请求之前直接关闭侦听套接字(侦听套接字是 fileno 0),但这不起作用。

谢谢。

4

1 回答 1

0

问题是因为 mod_fastcgi 是旧版本 - 2.4.2 升级到 2.4.6 解决了它。

另外,mod_fcgid 没有这个问题。

于 2012-07-06T06:39:33.440 回答