我正在尝试设置Perl Catalyst插件Catalyst :: Plugin :: RunAfterRequest,并且在使用服务器脚本“APPNAME / script / APPNAME_server.pl”和Lighttpd下的FastCGI进程运行时看到了不同的行为。
也就是说,它与服务器脚本一样正常工作,但是当在FastCGI Web服务器环境中使用时,返回的请求似乎被请求返回后涉嫌运行的代码阻止。使用Controller / Root.pm中的代码很容易重现:
sub index : Private {
my ($self, $c) = @_;
$c->run_after_request(
sub {sleep 10;}
);
$c->response->body("foobar");
}
运行测试脚本会按预期立即返回结果,但会在Web服务器环境中的响应之前等待10秒。
是否需要使用Lighttpd或FastCGI进行配置才能使其正常工作?
更新:
根据要求,示例lighttpd config:
include "common/mime.conf"
include "common/modules-core.conf"
server.bind = "127.0.0.1"
server.port = 6080
server.pid-file = "/path/to/lighttpd-6080.pid"
server.username = "user"
server.groupname = "group"
server.document-root = "/path/to/root"
server.errorlog = "/path/to/.errors-6080"
accesslog.filename = "/path/to/.access-6080"
include "common/index.conf"
server.modules += ( "mod_fastcgi")
server.stream-response-body = 2
$HTTP["url"] !~ "^/(?:img/|static/|css/|favicon.ico$)" {
fastcgi.server = (
"" => (
"appname" => (
"socket" => "/path/to/appname-fcgi.sock",
"check-local" => "disable",
"bin-path" => "/path/to/appname_fastcgi.pl",
"min-procs" => 2,
"max-procs" => 5,
"idle-timeout" => 20
)
)
)
}