my $env_pass = '';
if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) {
my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
- return unless $level =~ /^\w+$/;
- $env_pass = '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
+ $env_pass .= '$ENV{OBJECT_REMOTE_LOG_LEVEL} = "' . $level . "\";\n";
+}
+if (defined($ENV{OBJECT_REMOTE_LOG_FORMAT})) {
+ my $format = $ENV{OBJECT_REMOTE_LOG_FORMAT};
+ $env_pass .= '$ENV{OBJECT_REMOTE_LOG_FORMAT} = "' . $format . "\";\n";
}
my $start = stripspace <<'END_START';
#this is invoked on all nodes
sub init_logging {
my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
+ my $format = $ENV{OBJECT_REMOTE_LOG_FORMAT};
return unless defined $level;
+ $format = "[%l %r] %s" unless defined $format;
my $logger = Object::Remote::Logging::Logger->new(
- min_level => lc($level),
+ min_level => lc($level), format => $format,
level_names => Object::Remote::Logging::arg_levels(),
);
use Moo;
use Scalar::Util qw(weaken);
-has format => ( is => 'ro', required => 1, default => sub { '[%l %r] %f:%i %p::%m %s' } );
+has format => ( is => 'ro', required => 1, default => sub { '%l: %s' } );
has level_names => ( is => 'ro', required => 1 );
has min_level => ( is => 'ro', required => 1 );
has max_level => ( is => 'ro' );
}
sub _build_perl_command {
- my ($self) = @_;
+ my ($self) = @_;
my $nice = $self->nice;
my $ulimit = $self->ulimit;
- my $shell_code = '';
-
+ my $perl_path = 'perl';
+ my $shell_code = '';
+
if (defined($ulimit)) {
- $shell_code .= "ulimit -v $ulimit; ";
+ $shell_code .= "ulimit $ulimit || exit 1; ";
}
-
+
if (defined($nice)) {
$shell_code .= "nice -n $nice ";
}
-
- $shell_code .= 'perl -';
-
- return [ 'sh', '-c', $shell_code ];
+
+ if (defined($ENV{OBJECT_REMOTE_PERL_PATH})) {
+ log_debug { "Using OBJECT_REMOTE_PERL_PATH environment variable as perl path" };
+ $perl_path = $ENV{OBJECT_REMOTE_PERL_PATH};
+ }
+
+ $shell_code .= $perl_path . ' -';
+
+ return [ 'bash', '-c', $shell_code ];
}
+
around connect => sub {
my ($orig, $self) = (shift, shift);
my $f = $self->$start::start($orig => @_);