Coming Underground
« Strange Puppet nil:NilClass error messageMythTV video streaming hack »

Debugging Perl CGI scripts with Lighttpd

Permalink 2010-03-11 10:37, by jaervosz, Categories: General, Gentoo Tips, Universe/English , Tags: debugging, lighttpd, perl

I've never used Lighttpd much before usually using Apache. However recently I started serviing Nagios from Lighttpd and since my MythTV backend is running on the same system I'm serving my Mythweb from Lighttpd as well. While hacking it a bit I discovered that Lighttpd doesn't log Perl errors to the standard lighttpd error log. It appears that versions after 1.4.19 doesn't allow CGIs to write to the error file or I did something completely wrong with my installation.

I worked around the problem by using CARP:

--- handler.pl.orig     2010-03-10 15:28:29.000000000 +0100
+++ handler.pl  2010-03-10 15:29:06.000000000 +0100
@@ -14,4 +14,10 @@
 # Other includes
     use Sys::Hostname;
+# hack to allow lighttpd to log cgi errors
+# http://redmine.lighttpd.net/boards/2/topics/16
+    my $logfile = ">>/var/log/lighttpd/mycgi-log";
+    use CGI::Carp qw(carpout);
+    open(LOG, $logfile) or  print header(), "Unable to open log $logfile.";
+    carpout(LOG);
 
     require "modules/$Path[0]/tv.pl";

Update: You can download the patch here: mythweb-0.22_p22763-carppout-debug.patch

Leave a comment »Send a trackback »

Trackback address for this post

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

©2010 by admin

Contact Jaervosz