From: Chris Prather Date: Tue, 11 Sep 2007 09:44:52 +0000 (+0000) Subject: document is_daemon X-Git-Tag: 0.02~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e7a196e7340f91f13006a6af6873d105dbc187d4;p=gitmo%2FMooseX-Daemonize.git document is_daemon r28840@alice-3: perigrin | 2007-09-11 04:45:00 -0500 more patches from dec --- diff --git a/Changes b/Changes index 2424740..919fcc9 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,10 @@ Revision history for MooseX-Daemonize 0.02 ??? + - Fixed bug where sometimes the pidfile is writeable but pidbase is not -- reported by dec + - Fixed bug where the pidfile wasn't being updated properly -- reported by dec + - Added is_daemon attribute + - Added another fork to make sure we short circuit out of the daemonize process properly - Switch to File::Pid - Add the GetOpt prereq - Adjust the kill timings diff --git a/lib/MooseX/Daemonize.pm b/lib/MooseX/Daemonize.pm index 2a12ce8..a59f794 100644 --- a/lib/MooseX/Daemonize.pm +++ b/lib/MooseX/Daemonize.pm @@ -50,8 +50,8 @@ has pidfile => ( coerce => 1, predicate => 'has_pidfile', default => sub { - die 'Cannot write to ' . $_[0]->pidbase unless -w $_[0]->pidbase; my $file = $_[0]->pidbase . '/' . $_[0]->progname . '.pid'; + die "Cannot write to $file" unless (-e $file ? -w $file : -w $_[0]->pidbase); File::Pid->new( { file => $file } ); }, handles => { @@ -226,6 +226,10 @@ The file we store our PID in, defaults to /var/run/$progname/ If true, the process won't background. Useful for debugging. This option can be set via Getopt's -f. +=item is_daemon Bool + +If true, the process is the backgrounded process. This is useful for example in an after 'start' => sub { } block + =back =head1 METHODS diff --git a/t/perlcritic.t b/t/perlcritic.t index 7e7b210..00999d9 100644 --- a/t/perlcritic.t +++ b/t/perlcritic.t @@ -1,6 +1,7 @@ #!perl - -if (!require Test::Perl::Critic) { +use Test::More; +eval "require Test::Perl::Critic"; +if (! $@) { Test::More::plan( skip_all => "Test::Perl::Critic required for testing PBP compliance" );