Siebel-Srvrmgr
view release on metacpan or search on metacpan
lib/Siebel/Srvrmgr/Daemon/Offline.pm view on Meta::CPAN
package Siebel::Srvrmgr::Daemon::Offline;
=pod
=head1 NAME
Siebel::Srvrmgr::Daemon::Offline - subclass that reads srvrmgr output from a file
=head1 SYNOPSIS
use Siebel::Srvrmgr::Daemon::Offline;
my $daemon = Siebel::Srvrmgr::Daemon::Offline->new(
{
output_file => File::Spec->catfile('some', 'location', 'to', 'srvrmgr', 'output', 'file'),
field_delimiter => $field_delimiter;
}
);
$daemon->run();
=head1 DESCRIPTION
This is a subclass of L<Siebel::Srvrmgr::Daemon> used to execute the C<srvrmgr> program in batch mode.
This class also uses the L<Siebel::Srvrmgr::Daemon::Cleanup> role.
=cut
use Moose 2.0401;
use namespace::autoclean 0.13;
use Siebel::Srvrmgr::Daemon::ActionFactory;
use Carp qw(longmess);
use File::Temp 0.2304 qw(:POSIX);
use Data::Dumper;
use Siebel::Srvrmgr;
use File::BOM 0.14 qw(:all);
use Try::Tiny 0.27;
our $VERSION = '0.29'; # VERSION
extends 'Siebel::Srvrmgr::Daemon';
with 'Siebel::Srvrmgr::Daemon::Cleanup';
=pod
=head1 ATTRIBUTES
=head2 output_file
A string representing the full pathname to the file that contains all output from srvrmgr program to be parsed.
Required during object creation, this is a read-write attribute.
=cut
has output_file => (
isa => 'Str',
is => 'rw',
reader => 'get_output_file',
writer => '_set_output_file',
required => 1
);
=head2 field_delimiter
An optional, read-write parameter during object creation.
If the file defined by C<output_file> has fields separated by a delimiter, you must set this attribute or output parsing will fail.
If setup, expects a single character.
=cut
has field_delimiter => ( is => 'rw', isa => 'Chr', reader => 'get_field_del', writer => 'set_field_del' );
=head2 run
This method completely overrides the parent's L<Siebel::Srvrmgr::Daemon> method.
It will then parse the file defined in the C<output_file> attribute, executing any action defined during object creation.
=cut
override 'run' => sub {
my ( $self ) = @_;
my $logger = Siebel::Srvrmgr->gimme_logger( blessed($self) );
$logger->info('Starting run method');
my $parser = $self->create_parser($self->get_field_del);
my $in;
try {
open_bom( $in, $self->get_output_file(), ':utf8' );
}
catch {
$logger->logdie(
'Cannot read ' . $self->get_output_file() . ': ' . $_ );
( run in 1.780 second using v1.01-cache-2.11-cpan-b16cb0d3907 )