Baltasar Cevc wrote:
Hi everybody,
yesterday, when writing the core of another daemon intended to run on one of the servers I administer, I caught myself copy-pasting code from other daemons. Not some lines but more or less the whole main part.
After a bit of thinking, I realized that there must be a better solution. Probably hidden somewhere in CPAN. However, even after searching quite a long time; I haven't found one. None - or should I rather say that I found a whole bunch of them?
There are modules (App::Control, Proc::PID::File, File::PID etc.), all of them doing just one thing, exactly in the standard Unix manner. But at least as far as I can see, in this specific case, it leads into having quite some code a in every daemon which is more or less redundant.
(slight tangent)
Pidfile manipulation is genericly useful, even outside of daemons. For example, I have normal, command-line applications that use pidfiles to ensure only one instance is run at a time, to prevent screw-ups if our scheduling software goes wacky. I also use a pid-collection-file for another app I wrote. It runs dozens of processes on dozens of remote machines, and as each process starts up, it adds it host and pid info to the collective file. That way, if the main process crashes or is killed, I can use a quick utility I wrote to read through the pid-colleciton-file and track down and kill the remote child processes.
In other words, I'd love to see this type of stuff available outside the context of daemon class. :)
You said you encountered "App::Control, Proc::PID::File, File::PID etc." as part of your research. What did you learn about them? Can you write up a quick comparison? Are any of them actually useful?
(so looking forward to that cpan wiki - coming soon, I believe)
-ofer