From: Tyler Riddle Date: Wed, 7 Nov 2012 02:48:43 +0000 (-0800) Subject: new env vars: OBJECT_REMOTE_PERL_PATH and OBJECT_REMOTE_LOG_FORMAT X-Git-Tag: v0.003001_01~86 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0fe333eb337345ecc842a14bf738b5db837936b0;p=scpubgit%2FObject-Remote.git new env vars: OBJECT_REMOTE_PERL_PATH and OBJECT_REMOTE_LOG_FORMAT --- diff --git a/lib/Object/Remote/FatNode.pm b/lib/Object/Remote/FatNode.pm index a09680f..fdb2a22 100644 --- a/lib/Object/Remote/FatNode.pm +++ b/lib/Object/Remote/FatNode.pm @@ -64,8 +64,11 @@ my @after_inc; 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'; diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm index eb336a5..22860ed 100644 --- a/lib/Object/Remote/Logging.pm +++ b/lib/Object/Remote/Logging.pm @@ -34,9 +34,11 @@ sub arg_levels { #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(), ); diff --git a/lib/Object/Remote/Logging/Logger.pm b/lib/Object/Remote/Logging/Logger.pm index 7c42a58..16b278d 100644 --- a/lib/Object/Remote/Logging/Logger.pm +++ b/lib/Object/Remote/Logging/Logger.pm @@ -3,7 +3,7 @@ package Object::Remote::Logging::Logger; 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' ); diff --git a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm index 32cb877..670ad73 100644 --- a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm +++ b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm @@ -31,24 +31,31 @@ sub _build_module_sender { } 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 => @_);