如何调试快速公共网关接口(FCGI)程序? [英] How to debug a Fast Common Gateway Interface (FCGI) program?
问题描述
我遇到一个问题,我不知道如何调试用C ++编写的FCGI程序,并且基于 fastcgi 。
该程序由Lighttpd管理 spawn-fcgi 并通过nginx fastcgi模块调用。
我写了一个shell脚本来重新启动 spawn-cgi :
#! / bin / bash
cgi_default =index.cgi
process_pid =pid
param_ip =127.0.0.1
param_port = 9000
if [-f$ process_pid];然后
pid =`cat $ process_pid`
kill -9 $ pid&> / dev / null
rm $ process_pid
fi
spawn_out =`/ usr / local / bin / spawn-fcgi -a $ param_ip -p $ param_port $ cgi_default`
#spawn-fcgi:child spawned successfully:PID:6423
pid =`echo $ spawn_out | cut -d-f6`
expr $ pid + 0&> / dev / null
[$? -eq0]&& echo$ pid> $ process_pid
程序 index.cgi 已成功构建,
$ b $ b
location / {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
现在我在 index.cgi 更改一些代码(可能有错误的逻辑)。程序崩溃,并在我的浏览器中返回了 502 Bad Gateway 。
我很难找出我的程序出了什么问题,因为fcgi程序作为nginx的回调函数。
那么如何正确和方便地调试我的程序?
是的,gdb attach的运行过程调试会有很多帮助。
I encountered a problem that I don't known how to debug a FCGI program which written in C++ and based on fastcgi.
The program is managed by Lighttpd spawn-fcgi and called by nginx fastcgi module.
I wrote a shell script to restart spawn-cgi:
#! /bin/bash
cgi_default="index.cgi"
process_pid="pid"
param_ip="127.0.0.1"
param_port="9000"
if [ -f "$process_pid" ]; then
pid=`cat $process_pid`
kill -9 $pid &> /dev/null
rm $process_pid
fi
spawn_out=`/usr/local/bin/spawn-fcgi -a $param_ip -p $param_port $cgi_default`
# spawn-fcgi: child spawned successfully: PID: 6423
pid=`echo $spawn_out | cut -d " " -f6`
expr $pid + 0 &> /dev/null
[ $? -eq "0" ] && echo "$pid" > $process_pid
The program index.cgi was successfully built and just printf some strings to out stream.
And my configuration in nginx:
location / {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
Now I am wroking on index.cgi, change some code (maybe with faulty logic). The program crashed and 502 Bad Gateway was returned in my browser.
It's hard for me to find out what is wrong in my program because the fcgi progam acts as a callback function of nginx. So I cannot press Debug button and bebug my program normally.
So how can I debug my program properly and conveniently?
Yeah, gdb attach the running process debugging will help a lot.
这篇关于如何调试快速公共网关接口(FCGI)程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!