| « Strange Puppet nil:NilClass error message | MythTV video streaming hack » |
Debugging Perl CGI scripts with Lighttpd
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