Enhancing a Perl-UNIX Daemon: Integration with System Logs
Dave Aiello wrote, "Last week, I talked about the minimal changes that are required to daemonize a Perl program originally designed to run as a UNIX cron job. I have to admit that the approach I suggested was too simplistic for my application."
"I took down the new daemon within six hours because it was silently dying-- something a UNIX daemon obviously can't be allowed to do. And, simply sending standard output and standard error to /dev/null, as the WebReference tutorial suggested, didn't help me understand what the problem was."
"This time, I went to my bookshelf for guidance, and picked up Lincoln Stein's excellent
Network Programming with Perl, published by Addison-Wesley. There is a lot of information in this book that is applicable to this problem. I found Chapter 14, Bulletproofing Servers, to be particularly useful. It talks about using Sys::Syslog to write status messages to the system error log, and to overload warn() and die() so that they are logged in the same fashion."
"The chapter also takes a simple server that had been written in previous examples in the book and adds these features to it. When making significant changes to programs like this, it's always useful to be able to compare the before and after states of an example."
"I am going to try to implement the recommended changes in my own daemon today, and I will report on the value of these changes in a future article."