From: Stevan Little Date: Mon, 3 Dec 2007 17:54:22 +0000 (+0000) Subject: some additional cleanup X-Git-Tag: 0_06~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fe0eeebc050311829e0f93a2d86018be78598d47;p=gitmo%2FMooseX-Daemonize.git some additional cleanup --- diff --git a/Changes b/Changes index ac7b3b5..5706f0b 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,12 @@ Revision history for MooseX-Daemonize about undead process - Added stop_timeout to allow user to control timings. - Refactored to roles + - removed Proc::Daemon dependency + - removed File::Pid dependency + + * Test::MooseX::Daemonize + - updated docs + - removed Proc::Daemon dependency * MooseX::Daemonize::Core - the core daemonization methods are here @@ -24,14 +30,15 @@ Revision history for MooseX-Daemonize - added tests for this (stevan) 0.04 2007-11-11 - - Fix stupid perlcritic.t cause the Module::Starter::PBP tests were stupid but I didn't realize it. + - 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/README b/README index 1aa72e4..1257538 100644 --- a/README +++ b/README @@ -1,19 +1,4 @@ -MooseX-Daemonize version 0.0.1 - -[ REPLACE THIS... - - The README is used to introduce the module and provide instructions on - how to install the module, any machine dependencies it may have (for - example C compilers and installed libraries) and any other information - that should be understood before the module is installed. - - A README file is required for CPAN modules since CPAN extracts the - README file from a module distribution so that people browsing the - archive can use it get an idea of the modules uses. It is usually a - good idea to provide version information here so that people can - decide whether fixes for the module are worth downloading. -] - +MooseX-Daemonize version 0.0.5 INSTALLATION @@ -32,12 +17,11 @@ Alternatively, to install with Module::Build, you can use the following commands ./Build test ./Build install - - DEPENDENCIES -None. - + Moose + MooseX::Getopt + MooseX::Types::Path::Class COPYRIGHT AND LICENCE diff --git a/lib/Test/MooseX/Daemonize.pm b/lib/Test/MooseX/Daemonize.pm index 8488621..c5efab6 100644 --- a/lib/Test/MooseX/Daemonize.pm +++ b/lib/Test/MooseX/Daemonize.pm @@ -1,12 +1,11 @@ -use strict; - package Test::MooseX::Daemonize; -use Proc::Daemon; +use strict; # BEGIN CARGO CULTING use Sub::Exporter; use Test::Builder; -our $VERSION = '0.02'; + +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:PERIGRIN'; { @@ -33,7 +32,7 @@ sub daemonize_ok { } else { sleep(1); # Punt on sleep time, 1 seconds should be enough - $Test->ok( -e $daemon->pidfile->file, $msg ) + $Test->ok( $daemon->pidfile->does_file_exist, $msg ) || $Test->diag( 'Pidfile (' . $daemon->pidfile->file . ') not found.' ); } @@ -93,17 +92,16 @@ after daemonize => sub { 1; __END__ +=pod =head1 NAME -Test::MooseX::Daemonize - provides a Role that daemonizes your Moose based application. - +Test::MooseX::Daemonize - Tool to help test MooseX::Daemonize applications =head1 VERSION This document describes MooseX::Daemonize version 0.0.1 - =head1 SYNOPSIS package main; @@ -122,117 +120,35 @@ This document describes MooseX::Daemonize version 0.0.1 =head1 DESCRIPTION -Often you want to write a persistant daemon that has a pid file, and responds appropriately to Signals. -This module helps provide the basic infrastructure to do that. - -=head1 ATTRIBUTES - -=over - -=item progname Str - -The name of our daemon, defaults to $0 - -=item pidbase Str - -The base for our bid, defaults to /var/run/$progname - -=item pidfile Str - -The file we store our PID in, defaults to /var/run/$progname/ - -=item foreground Bool - -If true, the process won't background. Useful for debugging. This option can be set via Getopt's -f. - -=back - -=head1 METHODS - -=over - -=item check() - -Check to see if an instance is already running. - -=item start() +This module provides some basic Test::Builder compatible test methods to +use when writing tests for you MooseX::Daemonize based modules. -Setup a pidfile, fork, then setup the signal handlers. +=head1 EXPORTED FUNCTIONS -=item stop() +=over 4 -Stop the process matching the pidfile, and unlinks the pidfile. +=item B -=item restart() +This will attempt to daemonize your C<$daemon> returning ok on +success and not ok on failure. -Litterally +=item B - $self->stop(); - $self->start(); - -=item daemonize() - -Calls C to daemonize this process. - -=item kill($pid) - -Kills the process for $pid. This will try SIGINT, and SIGTERM before falling back to SIGKILL and finally giving up. - -=item setup_signals() - -Setup the signal handlers, by default it only sets up handlers for SIGINT and SIGHUP - -=item handle_sigint() - -Handle a INT signal, by default calls C<$self->stop()>; - -=item handle_sighup() - -Handle a HUP signal. Nothing is done by default. - -=item meta() - -the C method from L - -=item daemonize_ok() - -=item check_test_output() +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 +more info. If we get time we will document this more thoroughly. =back -=head1 DEPENDENCIES - -=for author to fill in: - A list of all the other modules that this module relies upon, - including any restrictions on versions, and an indication whether - the module is part of the standard Perl distribution, part of the - module's distribution, or must be installed separately. ] - -Obviously L, also L, L, L, L - =head1 INCOMPATIBILITIES -=for author to fill in: - A list of any modules that this module cannot be used in conjunction - with. This may be due to name conflicts in the interface, or - competition for system or program resources, or due to internal - limitations of Perl (for example, many modules that use source code - filters are mutually incompatible). - None reported. - =head1 BUGS AND LIMITATIONS -=for author to fill in: - A list of known problems with the module, together with some - indication Whether they are likely to be fixed in an upcoming - release. Also a list of restrictions on the features the module - does provide: data types that cannot be handled, performance issues - and the circumstances in which they may arise, practical - limitations on the size of data sets, special cases that are not - (yet) handled, etc. - No bugs have been reported. Please report any bugs or feature requests to @@ -241,13 +157,12 @@ L. =head1 SEE ALSO -L, L, L +L =head1 AUTHOR Chris Prather C<< >> - =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Chris Prather C<< >>. All rights reserved. @@ -255,7 +170,6 @@ Copyright (c) 2007, Chris Prather C<< >>. All rights reserve This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. - =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY @@ -278,3 +192,5 @@ RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +=cut diff --git a/t/20.core.t b/t/20.core.t index 0159b57..f0161ee 100644 --- a/t/20.core.t +++ b/t/20.core.t @@ -97,4 +97,7 @@ if (DEBUG) { ok(!$p->is_running, '... the daemon process is no longer running (' . $p->pid . ')'); +unlink $ENV{MX_DAEMON_STDOUT}; +unlink $ENV{MX_DAEMON_STDERR}; + diff --git a/t/30.with_pid_file.t b/t/30.with_pid_file.t index e26d142..2e6f718 100644 --- a/t/30.with_pid_file.t +++ b/t/30.with_pid_file.t @@ -104,3 +104,5 @@ if (DEBUG) { 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};