分析超时的Perl CGI脚本

el.*_*ado 6 perl cgi http-status-code-504 devel-nytprof

我有一个Perl CGI应用程序,有时超时,导致它被Apache杀死,并将504 Gateway Time-out错误发送到浏览器.我试图使用NYTProf来描述这个应用程序,但我无法读取配置文件数据:

 $ nytprofhtml -f www/cgi-local/nytprof.out
Reading www/cgi-local/nytprof.out
Profile data incomplete, inflate error -5 ((null)) at end of input file, perhaps the process didn't exit cleanly or the file has been truncated  (refer to TROUBLESHOOTING in the documentation)
Run Code Online (Sandbox Code Playgroud)

我正在使用sigexit=1NYTProf选项.这是重现问题的最小CGI脚本:

#!/usr/bin/perl -d:NYTProf

sleep 1 while 1;
Run Code Online (Sandbox Code Playgroud)

Thi*_*Not 6

设置sigexit=1告诉NYTProf捕获以下信号:

INT HUP PIPE BUS SEGV
Run Code Online (Sandbox Code Playgroud)

但是,当您的CGI脚本超时时,Apache会发送SIGTERM.你需要抓住SIGTERM:

sigexit=term
Run Code Online (Sandbox Code Playgroud)

要捕获SIGTERM默认信号,请使用:

sigexit=int,hup,pipe,bus,segv,term
Run Code Online (Sandbox Code Playgroud)