|laziness, impatience, and hubris|
Executing script in normal/daemon mode and adding start/stop capabilityby chanakya (Friar)
|on Oct 07, 2009 at 10:56 UTC||Need Help??|
chanakya has asked for the
wisdom of the Perl Monks concerning the following question:
I have a bunch of scripts which monitor incoming email, process them and load parsed data into Mysql.
I'm demonizing the scripts, in order to process the incoming emails at a faster rate. I have implemented
Proc::Daemon to achieve this. All is well till now.
I'm planning to add modes (like normal mode or daemon mode) to the script, so that I can execute
scripts in daemon mode via the cron, and use the normal mode if I want to troubleshoot or manually
load some emails.
In my code below I have added the daemon mode via the command line options.
Here I need your suggestion on how can i simplify the code and also remove duplicated code. The code shown is a sample script, and the code for some of the scripts is long.
The above code works perfectly in the daemon mode and normal mode.
Here's my two questions and seeking suggestions to improve the code
* How can avoid code duplication
* How can I add start/stop commands for the script. thank you for your time