perl - 分析超时的 Perl CGI 脚本

标签 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)

我正在使用 sigexit=1 NYTProf 选项。这是重现问题的最小 CGI 脚本:
#!/usr/bin/perl -d:NYTProf

sleep 1 while 1;

最佳答案

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

INT HUP PIPE BUS SEGV

但是,当您的 CGI 脚本超时时,Apache 会发送 SIGTERM .你需要 catch SIGTERM :
sigexit=term

catch SIGTERM除了默认信号外,还可以使用:
sigexit=int,hup,pipe,bus,segv,term

关于perl - 分析超时的 Perl CGI 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20739231/

相关文章:

windows - 如何将此代码从 Visual Basic 转换为 Perl?

perl - 了解 newRV_inc 与 newRV_noinc

python - mod_wsgi、mod_python,还是只是 cgi?

php - 调试504网关超时及实际原因及解决方法

arrays - 在有但有一个转折中获得完全匹配

regex - 为什么此代码会跳过所有其他输入行

http - 来自脚本的格式错误的 header 。错误 header =HTTP/1.1 302 找到

linux - 脚本无法确认文件夹,即使它们存在

Python模拟504网关超时错误

authentication - linkedin oauth2登录返回 "504 Gateway Time-out"