Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get perl script errors in nginx error log (Nginx with FCGIwrap)

I just installed fcgiwrap and spawn-fcgi to be able to use perl scripts in nginx. I added something like this in my site config:

location ~ \.pl$ {
    gzip off;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    include fastcgi_params;
    fastcgi_index index.pl;
}

It works but browser shows the following message if there is an error in perl code:

An error occurred while reading CGI reply (no response received)

And I am not able to find perl errors in the nginx logs. "perl -c" on the command line helps if there are perl compilation errors but it does not help me solve runtime errors.

How can I tell perl or fcgiwrap to save errors in nginx error log or some other log file?

like image 243
toktok Avatar asked Mar 30 '12 10:03

toktok


1 Answers

There are a number of nice tools to capture run-time errors of Perl web apps and show them to you. These debugging tools can be disabled in production through various means. They basically "eval" the bulk of the code, allow them to handle most errors. Some examples:

  • Plack::Middleware::Debug, for any PSGI app
  • CGI::Application::Plugin::DebugScreen for CGI::Application projects
  • Catalyst::Plugin::StackTrace, an option with Catalyst.
  • CGI::Carp has 'fatalsToBrowser' for older code or simple cases.
like image 71
Mark Stosberg Avatar answered Nov 15 '22 10:11

Mark Stosberg