X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FDaemonize%2FPid.pm;fp=lib%2FMooseX%2FDaemonize%2FPidFile.pm;h=0faaedba0b75012cb5aa9e75fe06fc563e8f4032;hb=d8985b7d3e86e39f0f78636e58019504b805adac;hp=169b3c3cc515c70b39e6ef280c914c9f702f6770;hpb=289fcbc7afd4eee6c6b41e48dda1507942c5fd29;p=gitmo%2FMooseX-Daemonize.git diff --git a/lib/MooseX/Daemonize/PidFile.pm b/lib/MooseX/Daemonize/Pid.pm similarity index 74% rename from lib/MooseX/Daemonize/PidFile.pm rename to lib/MooseX/Daemonize/Pid.pm index 169b3c3..0faaedb 100644 --- a/lib/MooseX/Daemonize/PidFile.pm +++ b/lib/MooseX/Daemonize/Pid.pm @@ -1,44 +1,17 @@ -package MooseX::Daemonize::PidFile; +package MooseX::Daemonize::Pid; use strict; # because Kwalitee is pedantic use Moose; -use MooseX::Daemonize::Types; - our $VERSION = '0.01'; has 'pid' => ( is => 'rw', isa => 'Int', lazy => 1, - default => sub { - my $self = shift; - $self->does_file_exist - ? $self->file->slurp(chomp => 1) - : $$ - } -); - -has 'file' => ( - is => 'ro', - isa => 'Path::Class::File', - coerce => 1, - required => 1, - handles => [ 'remove' ] + default => sub { $$ } ); -sub does_file_exist { -s (shift)->file } - -sub write { - my $self = shift; - $self->file->openw->print($self->pid); -} - -sub running { - my $self = shift; - $self->does_file_exist - ? (kill(0, $self->pid) ? 1 : 0) - : 0; -} +sub is_running { kill(0, (shift)->pid) ? 1 : 0 } 1; @@ -48,7 +21,7 @@ __END__ =head1 NAME -MooseX::Daemonize::PidFile - PID file management for MooseX::Daemonize +MooseX::Daemonize::Pid - PID management for MooseX::Daemonize =head1 SYNOPSIS @@ -60,21 +33,13 @@ MooseX::Daemonize::PidFile - PID file management for MooseX::Daemonize =item pid Int -=item file Path::Class::File | Str - =back =head1 METHODS =over -=item remove - -=item write - -=item does_file_exist - -=item running +=item is_running =item meta()