Skip Menu |

This queue is for tickets about the App-Daemon CPAN distribution.

Report information
The Basics
Id: 50884
Status: resolved
Priority: 0/
Queue: App-Daemon

People
Owner: Nobody in particular
Requestors: matthew.byng-maddick [...] bbc.co.uk
Cc: mike.whitaker [...] bbc.co.uk
thomas.clark [...] bbc.co.uk
AdminCc:

Bug Information
Severity: Important
Broken in: 0.07
Fixed in: (no value)



CC: mike.whitaker [...] bbc.co.uk, thomas.clark [...] bbc.co.uk
Subject: App::Daemon takes the wrong order for options
App::Daemon does various command-line parsing bits to handle pid files, default logs etc. The app that is calling App::Daemon::daemonize() can initialise various values which represent sane defaults for that application (perhaps more sane than the App::Daemon internal ones. The priority for setting any of these values is therefore: app-internal > command line > App::Daemon internal defaults What should actually happen, however, is that you get a priority of something like: command line > app-internal > App::Daemon internal As this represents the properly specific -> generic hierarchy - going from - specific instance, to specific application to generic library. Patch to follow. Cheers MBM (CPAN:MATTBM)
As promised, patch attached that implements the behaviour I think should be there. Cheers MBM
--- App-Daemon-0.07/Daemon.pm.orig 2009-10-27 15:49:26.000000000 +0000 +++ App-Daemon-0.07/Daemon.pm 2009-10-27 16:02:50.000000000 +0000 @@ -30,20 +30,29 @@ pod2usage(); } - if(!defined $pidfile) { - $pidfile = find_option('-p', 1) || ( '/tmp/' . $appname . ".pid" ); + if(my $_pidfile = find_option('-p', 1)) { + $pidfile = $_pidfile; + } + else { + $pidfile ||= ( '/tmp/' . $appname . ".pid" ); } - if(!defined $logfile) { - $logfile = find_option('-l', 1) || ( '/tmp/' . $appname . ".log" ); + if(my $_logfile = find_option('-l', 1)) { + $logfile = $_logfile; + } + else { + $logfile ||= ( '/tmp/' . $appname . ".log" ); } - if(!defined $l4p_conf) { - $l4p_conf = find_option('-l4p', 1); + if(my $_l4p_conf = find_option('-l4p', 1)) { + $l4p_conf = $_l4p_conf; } - if(!defined $as_user) { - $as_user = find_option('-u', 1) || "nobody"; + if(my $_as_user = find_option('-u', 1)) { + $as_user = $_as_user; + } + else { + $as_user ||= 'nobody'; } if($> != 0) { @@ -51,14 +60,12 @@ ($as_user) = getpwuid($>); } - if(!defined $background) { - $background = find_option('-X') ? 0 : 1, - } + $background = 1 if(!defined $background); + $background = find_option('-X') ? 0 : $background; - if(!defined $loglevel) { - $loglevel = find_option('-v') ? $DEBUG : $INFO; - $loglevel = $DEBUG if !$background; - } + $loglevel = $background ? $INFO : $DEBUG + if(!defined $loglevel); + $loglevel = find_option('-v') ? $DEBUG : $loglevel; for (qw(start stop status)) { if( find_option( $_ ) ) {