From: Stevan Little Date: Sat, 17 Apr 2010 15:22:15 +0000 (-0400) Subject: 0.10 release X-Git-Tag: 0.15~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d85c76d2da46df3e779e574396f7eba5bf53fdb;p=gitmo%2FMooseX-Daemonize.git 0.10 release --- diff --git a/Changes b/Changes index c36a8d7..42b27b3 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,13 @@ Revision history for MooseX-Daemonize + +0.10 Sat. April 17, 2010 + - updated copyrights + - removed the POE test because it was causing + random failures when installing from CPAN + and not adding enough value to keep around + - applied POD corrections from RT #50091 + (thanks to Kostyuk Oleg) + 0.09 2009-10-05 * s/no_plan => 1/'no_plan'/g (Dave Rolsky) * Synchronize Version numbers @@ -11,11 +20,11 @@ Revision history for MooseX-Daemonize 0.07 Saturday, May 24, 2008 * MooseX::Daemonize - - Made default pidbase '/var/run' rather + - Made default pidbase '/var/run' rather than './var/run' - + * t/ - - Small fixups to pidfile testing in + - Small fixups to pidfile testing in t/31.with_pid_file_and_poe.t ~ Removed the Build.PL since Module::Install @@ -23,22 +32,22 @@ Revision history for MooseX-Daemonize 0.06 Fri. Dec. 21, 2007 * MooseX::Daemonize - - Fix logic that kills process so it doens't always warn + - Fix logic that kills process so it doens't always warn about undead process - Added stop_timeout to allow user to control timings. - Refactored to roles - removed Proc::Daemon dependency - removed File::Pid dependency - - added exit_code and status_message to capture the + - added exit_code and status_message to capture the exit code and a status message :) - refactored start/stop/restart to use these - added tests for this - added a &status command which returns a bool telling you if the daemon is running or not - added tests for this - + * Test::MooseX::Daemonize - - updated docs + - updated docs - removed Proc::Daemon dependency * MooseX::Daemonize::Core @@ -51,27 +60,27 @@ Revision history for MooseX-Daemonize * MooseX::Daemonize::Pid - added this package to replace the File::Pid stuff - + * MooseX::Daemonize::Pid::File - added this package to replace the File::Pid stuff, it is a subclass of MooseX::Daemonize::Pid (stevan) - added tests for this (stevan) 0.05 2007-11-18 - - Fix logic that kills process so it doens't always warn + - Fix logic that kills process so it doens't always warn about undead process - Added stop_timeout to allow user to control timings. 0.04 2007-11-11 - - Fix stupid perlcritic.t cause the Module::Starter::PBP tests were + - Fix stupid perlcritic.t cause the Module::Starter::PBP tests were stupid but I didn't realize it. 0.03 2007-10-22 - Add File::Slurp to dependencies so our tests pass better 0.02 Sept 19, 2007 - - 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 + - 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 diff --git a/Makefile.PL b/Makefile.PL index b21a588..98d1409 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,7 +6,8 @@ name 'MooseX-Daemonize'; all_from 'lib/MooseX/Daemonize.pm'; # Specific dependencies -build_requires 'Test::More' => 0; +build_requires 'Test::More' => 0; +build_requires 'Test::Moose' => 0; requires 'Moose' => 0.33; requires 'MooseX::Getopt' => 0.07; diff --git a/README b/README index af782a7..48c5801 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -MooseX-Daemonize version 0.08 +MooseX-Daemonize version 0.10 INSTALLATION @@ -17,7 +17,7 @@ DEPENDENCIES COPYRIGHT AND LICENCE -Copyright (C) 2007-2008, Chris Prather +Copyright (C) 2007-2010, Chris Prather This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/MooseX/Daemonize.pm b/lib/MooseX/Daemonize.pm index 875a05b..c7be66a 100644 --- a/lib/MooseX/Daemonize.pm +++ b/lib/MooseX/Daemonize.pm @@ -3,11 +3,11 @@ use strict; # because Kwalitee is pedantic use Moose::Role; use MooseX::Types::Path::Class; -our $VERSION = "0.09"; +our $VERSION = "0.10"; with 'MooseX::Daemonize::WithPidFile', 'MooseX::Getopt'; - + sub OK () { 0 } sub ERROR () { 1 } @@ -116,15 +116,15 @@ sub start { if ($self->pidfile->is_running) { $self->exit_code($self->OK); - $self->status_message('Daemon is already running with pid (' . $self->pidfile->pid . ')'); + $self->status_message('Daemon is already running with pid (' . $self->pidfile->pid . ')'); return !($self->exit_code); } - - if ($self->foreground) { + + if ($self->foreground) { $self->is_daemon(1); } - else { - eval { $self->daemonize }; + else { + eval { $self->daemonize }; if ($@) { $self->exit_code($self->ERROR); $self->status_message('Start failed : ' . $@); @@ -133,7 +133,7 @@ sub start { } unless ($self->is_daemon) { - $self->exit_code($self->OK); + $self->exit_code($self->OK); $self->status_message('Start succeeded'); return !($self->exit_code); } @@ -155,10 +155,10 @@ sub status { $self->clear_exit_code; if ($self->pidfile->is_running) { - $self->exit_code($self->OK); - $self->status_message('Daemon is running with pid (' . $self->pidfile->pid . ')'); + $self->exit_code($self->OK); + $self->status_message('Daemon is running with pid (' . $self->pidfile->pid . ')'); } - else { + else { $self->exit_code($self->ERROR); $self->status_message('Daemon is not running with pid (' . $self->pidfile->pid . ')'); } @@ -228,7 +228,7 @@ sub stop { # this just returns the OK # exit code for now, but # we should make this overridable - $self->exit_code($self->OK); + $self->exit_code($self->OK); $self->status_message("Not running"); } @@ -357,11 +357,11 @@ The name of our daemon, defaults to C<$package_name =~ s/::/_/>; =item I -The base for our bid, defaults to C +The base for our PID, defaults to C =item I -The file we store our PID in, defaults to C +The file we store our PID in, defaults to C<$pidbase/$progname.pid> =item I @@ -537,7 +537,7 @@ Some bug fixes sponsored by Takkle Inc. =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007-2009, Chris Prather C<< >>. Some rights +Copyright (c) 2007-2010, Chris Prather C<< >>. Some rights reserved. This module is free software; you can redistribute it and/or diff --git a/lib/MooseX/Daemonize/Core.pm b/lib/MooseX/Daemonize/Core.pm index d378612..3d3f1a9 100644 --- a/lib/MooseX/Daemonize/Core.pm +++ b/lib/MooseX/Daemonize/Core.pm @@ -3,7 +3,7 @@ use strict; # cause Perl::Critic errors are annoying use MooseX::Getopt; # to load the NoGetopt metaclass use Moose::Role; -our $VERSION = '0.09'; +our $VERSION = '0.10'; use POSIX (); @@ -232,9 +232,9 @@ I behavior in the C method. =item I -Setting this option to true will cause it to skip closing all the +Setting this option to true will cause it to skip closing all the filehandles, this is useful if you are opening things like sockets -and such in the pre-fork. +and such in the pre-fork. =back @@ -347,7 +347,7 @@ Stevan Little C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007-2008, Chris Prather C<< >>. All rights +Copyright (c) 2007-2010, Chris Prather C<< >>. All rights reserved. Portions heavily borrowed from L which is copyright Earl Hood. diff --git a/lib/MooseX/Daemonize/Pid.pm b/lib/MooseX/Daemonize/Pid.pm index 1f070df..2cbf754 100644 --- a/lib/MooseX/Daemonize/Pid.pm +++ b/lib/MooseX/Daemonize/Pid.pm @@ -2,10 +2,10 @@ package MooseX::Daemonize::Pid; use strict; # because Kwalitee is pedantic use Moose; use Moose::Util::TypeConstraints; -our $VERSION = '0.09'; +our $VERSION = '0.10'; -coerce 'MooseX::Daemonize::Pid' - => from 'Int' +coerce 'MooseX::Daemonize::Pid' + => from 'Int' => via { MooseX::Daemonize::Pid->new( pid => $_ ) }; @@ -29,10 +29,10 @@ __END__ =head1 NAME MooseX::Daemonize::Pid - PID management for MooseX::Daemonize - + =head1 DESCRIPTION -This is a very basic Pid management object, it doesn't do all that +This is a very basic Pid management object, it doesn't do all that much, and mostly just serves as a base class for L. =head1 ATTRIBUTES @@ -43,7 +43,7 @@ much, and mostly just serves as a base class for L =back -=head1 METHODS +=head1 METHODS =over 4 @@ -54,7 +54,7 @@ that the parent process does not have a bad value stored in it. =item B -This is a predicate method to tell you if your I attribute has +This is a predicate method to tell you if your I attribute has been initialized yet. =item B @@ -89,7 +89,7 @@ Stevan Little C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007-2008, Chris Prather C<< >>. All rights +Copyright (c) 2007-2010, Chris Prather C<< >>. All rights reserved. This module is free software; you can redistribute it and/or diff --git a/lib/MooseX/Daemonize/Pid/File.pm b/lib/MooseX/Daemonize/Pid/File.pm index a0a4047..03311a3 100644 --- a/lib/MooseX/Daemonize/Pid/File.pm +++ b/lib/MooseX/Daemonize/Pid/File.pm @@ -3,7 +3,7 @@ use strict; # because Kwalitee is pedantic use Moose; use Moose::Util::TypeConstraints; -our $VERSION = '0.09'; +our $VERSION = '0.10'; use MooseX::Types::Path::Class; use MooseX::Getopt::OptionTypeMap; @@ -12,16 +12,16 @@ use MooseX::Getopt::OptionTypeMap; # set up some basic coercions # that will come in handy # - SL -coerce 'MooseX::Daemonize::Pid::File' - => from 'Str' +coerce 'MooseX::Daemonize::Pid::File' + => from 'Str' => via { MooseX::Daemonize::Pid::File->new( file => $_ ) } - => from 'ArrayRef' - => via { MooseX::Daemonize::Pid::File->new( file => $_ ) } - => from 'Path::Class::File' + => from 'ArrayRef' + => via { MooseX::Daemonize::Pid::File->new( file => $_ ) } + => from 'Path::Class::File' => via { MooseX::Daemonize::Pid::File->new( file => $_ ) }; - + # NOTE: -# make sure this class plays +# make sure this class plays # well with MooseX::Getopt # - SL MooseX::Getopt::OptionTypeMap->add_option_type_to_map( @@ -31,7 +31,7 @@ MooseX::Getopt::OptionTypeMap->add_option_type_to_map( extends 'MooseX::Daemonize::Pid'; has '+pid' => ( - default => sub { + default => sub { my $self = shift; $self->does_file_exist ? $self->file->slurp(chomp => 1) @@ -70,17 +70,17 @@ __END__ =head1 NAME MooseX::Daemonize::Pid::File - PID file management for MooseX::Daemonize - + =head1 DESCRIPTION This object extends L to add persistence in a Pidfile. -This class sets up some basic coercion routines for itself so that it can +This class sets up some basic coercion routines for itself so that it can be created from a I (a file name), I (an array of path components -for a filename) or a I object. +for a filename) or a I object. This class registers it's type with L as well, and is expected -to be passed on the command line as a string (which will then go through the +to be passed on the command line as a string (which will then go through the coercion routines mentioned above). =head1 ATTRIBUTES @@ -89,14 +89,14 @@ coercion routines mentioned above). =item I -This is inherited from L and extended here to +This is inherited from L and extended here to get it's default value from the Pidfile (if available). =item I =back -=head1 METHODS +=head1 METHODS =over @@ -104,7 +104,7 @@ get it's default value from the Pidfile (if available). =item B -Both of these methods are inherited from L see that +Both of these methods are inherited from L see that module for more information. =item B @@ -152,7 +152,7 @@ Stevan Little C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007-2008, Chris Prather C<< >>. All rights +Copyright (c) 2007-2010, Chris Prather C<< >>. All rights reserved. This module is free software; you can redistribute it and/or diff --git a/lib/MooseX/Daemonize/WithPidFile.pm b/lib/MooseX/Daemonize/WithPidFile.pm index 33aa69e..e55d38d 100644 --- a/lib/MooseX/Daemonize/WithPidFile.pm +++ b/lib/MooseX/Daemonize/WithPidFile.pm @@ -2,7 +2,7 @@ package MooseX::Daemonize::WithPidFile; use strict; # cause Perl::Critic errors are annoying use MooseX::Getopt; # to load the Getopt metaclass use Moose::Role; -our $VERSION = '0.09'; +our $VERSION = '0.10'; use MooseX::Daemonize::Pid::File; @@ -13,7 +13,7 @@ requires 'init_pidfile'; has pidfile => ( # NOTE: - # this should always be accessible + # this should always be accessible # from the command line IMO # - SL metaclass => 'Getopt', @@ -28,7 +28,7 @@ has pidfile => ( after 'daemonize' => sub { my $self = shift; # NOTE: - # make sure that we do not have + # make sure that we do not have # any bad PID values stashed around # - SL $self->pidfile->clear_pid; @@ -65,8 +65,8 @@ MooseX::Daemonize::WithPidFile - A Role with the core daemonization and pidfile =head1 DESCRIPTION -This is a slightly extended basic daemonization Role, it provides -Pidfile management along with the core daemonization features +This is a slightly extended basic daemonization Role, it provides +Pidfile management along with the core daemonization features found in L. =head1 ATTRIBUTES @@ -76,7 +76,7 @@ found in L. =item I rw, isa => MooseX::Daemonize::Pid::File)> This attribute holds the L object used -to manage the Pidfile. It will initialize the object using the +to manage the Pidfile. It will initialize the object using the C method (which is required by this role). =back @@ -92,7 +92,7 @@ return a L object. =item B -This is a predicate method to tell you if your I attribute has +This is a predicate method to tell you if your I attribute has been initialized yet. =back @@ -103,7 +103,7 @@ been initialized yet. =item B -This adds an C method modifier to the C method (from +This adds an C method modifier to the C method (from L) and handles writing your Pidfile for you. =item B @@ -134,7 +134,7 @@ Stevan Little C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007-2008, Chris Prather C<< >>. All rights +Copyright (c) 2007-2010, Chris Prather C<< >>. All rights reserved. Portions heavily borrowed from L which is copyright Earl Hood. diff --git a/lib/Test/MooseX/Daemonize.pm b/lib/Test/MooseX/Daemonize.pm index 2841cd7..b45245b 100644 --- a/lib/Test/MooseX/Daemonize.pm +++ b/lib/Test/MooseX/Daemonize.pm @@ -1,7 +1,7 @@ package Test::MooseX::Daemonize; use strict; -our $VERSION = '0.09'; +our $VERSION = '0.10'; our $AUTHORITY = 'cpan:PERIGRIN'; # BEGIN CARGO CULTING @@ -104,7 +104,7 @@ Test::MooseX::Daemonize - Tool to help test MooseX::Daemonize applications This document describes MooseX::Daemonize version 0.0.1 =head1 SYNOPSIS - + use File::Spec::Functions; use File::Temp qw(tempdir); @@ -120,8 +120,8 @@ This document describes MooseX::Daemonize version 0.0.1 =head1 DESCRIPTION -This module provides some basic Test::Builder compatible test methods to -use when writing tests for you MooseX::Daemonize based modules. +This module provides some basic Test::Builder compatible test methods to +use when writing tests for you MooseX::Daemonize based modules. =head1 EXPORTED FUNCTIONS @@ -129,16 +129,16 @@ use when writing tests for you MooseX::Daemonize based modules. =item B -This will attempt to daemonize your C<$daemon> returning ok on +This will attempt to daemonize your C<$daemon> returning ok on success and not ok on failure. =item B -This is expected to be used with a C<$daemon> which does the +This is expected to be used with a C<$daemon> which does the B role (included in this package -see the source for more info). It will collect the test output -from your daemon and apply it in the parent process by mucking -around with L stuff, again, read the source for +see the source for more info). It will collect the test output +from your daemon and apply it in the parent process by mucking +around with L stuff, again, read the source for more info. If we get time we will document this more thoroughly. =back @@ -165,7 +165,7 @@ Chris Prather C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007-2008, Chris Prather C<< >>. All rights reserved. +Copyright (c) 2007-2010, Chris Prather C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. diff --git a/t/31.with_pid_file_and_poe.t b/t/31.with_pid_file_and_poe.t deleted file mode 100644 index 23ac3bb..0000000 --- a/t/31.with_pid_file_and_poe.t +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use File::Spec::Functions; - -use Test::More; -use Test::Exception; -use Test::Moose; - -use File::Temp qw(tempdir); - -my $dir = tempdir( CLEANUP => 1 ); - -BEGIN { - eval 'use POE::Kernel;'; - plan skip_all => "POE required for this test" if $@; - plan 'no_plan'; - use_ok('MooseX::Daemonize::Core'); - -} - -use constant DEBUG => 0; - -my $PIDFILE = catfile($dir, 'test-app.pid'); -$ENV{MX_DAEMON_STDOUT} = catfile($dir, 'Out.txt'); -$ENV{MX_DAEMON_STDERR} = catfile($dir, 'Err.txt'); - -unlink $PIDFILE; # clean up anythinf leftover by last run - -{ - package MyFooDaemon; - use Moose; - use POE; - - with 'MooseX::Daemonize::WithPidFile'; - - sub init_pidfile { - MooseX::Daemonize::Pid::File->new( file => $PIDFILE ) - } - - sub start { - my $self = shift; - - # this tests our bad PID - # cleanup functionality. - print "Our parent PID is " . $self->pidfile->pid . "\n" if ::DEBUG; - - $self->daemonize; - return unless $self->is_daemon; - - my $session = POE::Session->create( - inline_states => { - say_hello => sub { - my ($kernel, $heap) = @_[KERNEL, HEAP]; - - print "Hello from $$\n"; - - $heap->[0] = $kernel->delay_set('say_hello', 10); - }, - _start => sub { - my ($kernel, $heap) = @_[KERNEL, HEAP]; - $kernel->sig( INT => 'terminate'); - - $kernel->yield('say_hello'); - }, - terminate => sub { - my ($kernel, $heap) = @_[KERNEL, HEAP]; - $self->pidfile->remove if $self->pidfile->pid == $$; - } - }, - heap => [ 0 ] - ); - - - # make it easy to find with ps - $0 = 'test-app-2'; - POE::Kernel->run; - exit; - } -} - -my $d = MyFooDaemon->new( pidfile => $PIDFILE ); -isa_ok($d, 'MyFooDaemon'); -does_ok($d, 'MooseX::Daemonize::Core'); -does_ok($d, 'MooseX::Daemonize::WithPidFile'); - -ok($d->has_pidfile, '... we have a pidfile value'); - -{ - my $p = $d->pidfile; - isa_ok($p, 'MooseX::Daemonize::Pid::File'); - #diag $p->dump; -} - -ok(!(-e $PIDFILE), '... the PID file does not exist yet'); - -lives_ok { - $d->start; -} '... successfully daemonized from (' . $$ . ')'; - -my $p = $d->pidfile; -isa_ok($p, 'MooseX::Daemonize::Pid::File'); -#diag $p->dump; - -sleep(2); - -ok($p->does_file_exist, '... the PID file exists'); -ok($p->is_running, '... the daemon process is running (' . $p->pid . ')'); - -my $pid = $p->pid; -if (DEBUG) { - diag `ps $pid`; - diag "-------"; - diag `ps -x | grep test-app`; - diag "-------"; - diag "killing $pid"; -} -kill INT => $p->pid; -diag "killed $pid" if DEBUG; -sleep(2); -if (DEBUG) { - diag `ps $pid`; - diag "-------"; - diag `ps -x | grep test-app`; -} - -ok(!$p->is_running, '... the daemon process is no longer running (' . $p->pid . ')'); -ok(!(-e $PIDFILE), '... the PID file has been removed'); - -unlink $ENV{MX_DAEMON_STDOUT}; -unlink $ENV{MX_DAEMON_STDERR};