App-Foca
view release on metacpan or search on metacpan
lib/App/Foca/Server.pm view on Meta::CPAN
my $ip = $connection->peerhost();
log_info("Command - $name [timeout: $timeout][ip $ip] - About to run @foca_cmd");
$result = run_forked("@foca_cmd", {
child_in => \$in,
timeout => $timeout});
};
if ($result->{'timeout'} == $timeout) {
return (FOCA_RUN_RC_TIMEOUT_CMD, 'Timed out');
}
# Ok, sometimes because of SIG{CHLD} we get exit codes of 255
# with no stderr which foca thinks the command failed but it really did not,
# so lets check if we got stderr too, if we did not then the command was
# OK (unless of course there is a real: 'y' command). Check anything >
# than 1 cause 1 is by default an error (like /bin/false which wont
# return nothing to STDERR...)
if ($result->{'exit_code'} > 1) {
unless ($result->{'stderr'}) {
if (defined $cmd->{'real'}) {
if ($cmd->{'real'} ne 'y') {
# Force OK
$result->{'exit_code'} = 0;
}
} else {
# Force OK
$result->{'exit_code'} = 0;
}
}
lib/App/Foca/Server.pm view on Meta::CPAN
if ($result->{'exit_code'} > 0) {
my $output = '';
if ($capture_all) {
$output = $result->{'merged'};
} else {
if ($out) {
$output = $result->{'stdout'};
}
if ($err) {
$output = $result->{'stderr'};
}
}
$output = $result->{'merged'} unless $output;
$output = $@ unless $output;
$output = $result->{'err_msg'} unless $output;
$output =~ s#Can't ignore signal CHLD, forcing to default.(\n)?##g;
return (FOCA_RUN_RC_FAILED_CMD, $output);
} else {
my $output = '';
if ($capture_all) {
$output = $result->{'merged'};
} else {
if ($out) {
$output = $result->{'stdout'};
}
if ($err) {
$output = $result->{'stderr'};
}
}
$output = $result->{'merged'} unless $output;
$output =~ s#Can't ignore signal CHLD, forcing to default.(\n)?##g;
return (FOCA_RUN_RC_OK, $output);
}
} else {
return (FOCA_RUN_RC_MISSING_CMD, 'Missing command in commands file');
}
}
lib/App/Foca/Tools/Logger.pm view on Meta::CPAN
Creates the logger object.
=cut
sub init_logger {
my ($self) = @_;
# Foca logging goes to STDERR
my $log4perl_config = "log4perl.logger.Foca=DEBUG, Screen\n";
$log4perl_config .= "log4perl.appender.Screen=" .
"Log::Log4perl::Appender::Screen\n";
$log4perl_config .= "log4perl.appender.Screen.stderr=1\n";
$log4perl_config .= "log4perl.appender.Screen.layout=" .
"Log::Log4perl::Layout::PatternLayout\n";
$log4perl_config .= "log4perl.appender.Screen.DatePattern=" .
"yyyy-MM-dd\n";
$log4perl_config .= "log4perl.appender.Screen.layout.ConversionPattern=" .
"\%d \%p \%m \%n\n";
Log::Log4perl->init(\$log4perl_config);
$LOGGER = get_logger('Foca');
}
( run in 0.354 second using v1.01-cache-2.11-cpan-26ccb49234f )