File Coverage

blib/lib/App/Manoc/Netwalker/Script.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package App::Manoc::Netwalker::Script;
2             #ABSTRACT: Manoc Netwalker script runner
3              
4 1     1   4151 use Moose;
  1         3  
  1         6  
5              
6             our $VERSION = '2.99.2'; ##TRIAL VERSION
7              
8              
9             extends 'App::Manoc::Script::Daemon';
10              
11 1     1   6494 use POE;
  0            
  0            
12              
13             use App::Manoc::Netwalker::Config;
14             use App::Manoc::Netwalker::Control;
15             use App::Manoc::Netwalker::Scheduler;
16             use App::Manoc::Netwalker::Poller::Workers;
17             use App::Manoc::Netwalker::Discover::Workers;
18              
19              
20             sub main {
21             my $self = shift;
22              
23             $ENV{LANG} = 'C';
24              
25             $self->log->info("Starting netwalker");
26              
27             # get configuration and store it in a Config object
28             my %config_args = %{ $self->config->{Netwalker} || {} };
29             $config_args{manoc_config_dir} ||= $self->manoc_config_dir;
30              
31             my $config = App::Manoc::Netwalker::Config->new(%config_args);
32              
33             my $poller_workers = App::Manoc::Netwalker::Poller::Workers->new(
34             config => $config,
35             schema => $self->schema,
36             );
37              
38             my $discover_workers = App::Manoc::Netwalker::Discover::Workers->new(
39             config => $config,
40             schema => $self->schema,
41             );
42              
43             my $scheduler = App::Manoc::Netwalker::Scheduler->new(
44             config => $config,
45             schema => $self->schema,
46             );
47             $scheduler->add_workers($poller_workers);
48             $scheduler->add_workers($discover_workers);
49              
50             my $control = App::Manoc::Netwalker::Control->new(
51             config => $config,
52             poller => $poller_workers,
53             discoverer => $discover_workers,
54             );
55              
56             POE::Kernel->run();
57             }
58              
59              
60             # Clean up the namespace.
61             no Moose;
62             __PACKAGE__->meta->make_immutable;
63              
64             # Local Variables:
65             # mode: cperl
66             # indent-tabs-mode: nil
67             # cperl-indent-level: 4
68             # cperl-indent-parens-as-block: t
69             # End:
70              
71             __END__
72              
73             =pod
74              
75             =head1 NAME
76              
77             App::Manoc::Netwalker::Script - Manoc Netwalker script runner
78              
79             =head1 VERSION
80              
81             version 2.99.2
82              
83             =head1 DESCRIPTION
84              
85             This class is responsible for running the Netwalker daemon. It extends
86             L<App::Manoc::Script::Daemon> and sets up the pollers workers, the
87             scheduler and the control interface.
88              
89             =head2 SYNOPSIS
90              
91             use App::Manoc::Netwalker::Script;
92              
93             my $app = App::Manoc::Netwalker::Script->new_with_options();
94             $app->run();
95              
96             =head1 METHODS
97              
98             =head2 main
99              
100             The entry point for the script.
101              
102             =head1 SEE ALSO
103              
104             L<App::Manoc::Netwalker::Config>, L<App::Manoc::Netwalker::Control>, L<App::Manoc::Netwalker::Scheduler>, L<App::Manoc::Netwalker::Poller::Workers>, L<App::Manoc::Netwalker::Discover::Workers>
105              
106             =head1 AUTHORS
107              
108             =over 4
109              
110             =item *
111              
112             Gabriele Mambrini <gmambro@cpan.org>
113              
114             =item *
115              
116             Enrico Liguori
117              
118             =back
119              
120             =head1 COPYRIGHT AND LICENSE
121              
122             This software is copyright (c) 2017 by Gabriele Mambrini.
123              
124             This is free software; you can redistribute it and/or modify it under
125             the same terms as the Perl 5 programming language system itself.
126              
127             =cut