lib/Sys/Bprsync/Cmd/Command/run.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 93.1% 27 / 29 CC 1 SCAR 0.4
CC
1
Cov
90%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Sys/Bprsync/Cmd/Command/configcheck.pm ↑ Summary lib/Sys/Bprsync.pm »
1 package Sys::Bprsync::Cmd::Command::run;
2 {
3 $Sys::Bprsync::Cmd::Command::run::VERSION = '0.25';
4 }
5 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $Sys::Bprsync::Cmd::Command::run::AUTHORITY = 'cpan:TEX';
7 }
8 # ABSTRACT: run all pending sync jobs
9  
10 1 ▶use 5.010_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use feature ':5.10';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # use IO::Handle;
18 # use autodie;
19 # use MooseX::Params::Validate;
20 # use Carp;
21 # use English qw( -no_match_vars );
22 # use Try::Tiny;
23 1 ▶use Linux::Pidfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 0 ▶use Sys::Bprsync;
Subroutine BEGIN: called CC=1 SCAR=2.6
25  
26 # extends ...
27 extends 'Sys::Bprsync::Cmd::Command';
28 # has ...
29 has '_pidfile' => (
30 'is' => 'ro',
31 'isa' => 'Linux::Pidfile',
32 'lazy' => 1,
33 'builder' => '_init_pidfile',
34 );
35 # with ...
36 # initializers ...
37 sub _init_pidfile {
38 my $self = shift;
39  
40 my $PID = Linux::Pidfile::->new({
41 'pidfile' => $self->config()->get('Bprsync::Pidfile', { Default => '/var/run/bprsync.pid', }),
42 'logger' => $self->logger(),
43 });
44  
45 return $PID;
46 }
47  
48 # your code here ...
49 sub execute {
50 my $self = shift;
51  
52 $self->_pidfile()->create() or die('Script already running.');
53  
54 my $concurrency = $self->config()->get( 'Sys::Bprsync::Concurrency', { Default => 1, } );
55  
56 my $BP = Sys::Bprsync::->new(
57 {
58 'config' => $self->config(),
59 'logger' => $self->logger(),
60 'logfile' => $self->config()->get( 'Sys::Bprsync::Logfile', { Default => '/tmp/bprsync.log' } ),
61 'concurrency' => $concurrency,
62 }
63 );
64  
65 my $status = $BP->run();
66 $self->_pidfile()->remove();
67  
68 return $status;
69 }
70  
71 sub abstract {
72 return 'Do some syncs';
73 }
74  
75 no Moose;
76 __PACKAGE__->meta->make_immutable;
77  
78 1;
79  
80 __END__
« lib/Sys/Bprsync/Cmd/Command/configcheck.pm ↑ Summary lib/Sys/Bprsync.pm »