X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FRole%2FConnector%2FPerlInterpreter.pm;h=d418c236508b977b6b616c7de0465f60c03ea64a;hp=23ff0ea96d42ad578c59e57a5c8132c4a6673372;hb=4a9fa1a5a329754549f998536e0e68f19d42d7ab;hpb=fbd3b8ecbd2c9004f0e56ff1c0bc30f677a19c62 diff --git a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm index 23ff0ea..d418c23 100644 --- a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm +++ b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm @@ -5,6 +5,7 @@ use IO::Handle; use Object::Remote::ModuleSender; use Object::Remote::Handle; use Object::Remote::Future; +use Object::Remote::Logging qw( :log ); use Scalar::Util qw(blessed); use Moo::Role; @@ -19,12 +20,18 @@ sub _build_module_sender { return $hook ? $hook->sender : Object::Remote::ModuleSender->new; } +has perl_command => (is => 'lazy'); + +sub _build_perl_command { [ 'perl', '-' ] } + around connect => sub { my ($orig, $self) = (shift, shift); my $f = $self->$start::start($orig => @_); return future { $f->on_done(sub { my ($conn) = $f->get; + my $sub = $conn->remote_sub('Object::Remote::Logging::init_logging_forwarding'); + $sub->('Object::Remote::Logging', Object::Remote::Logging->arg_router); Object::Remote::Handle->new( connection => $conn, class => 'Object::Remote::ModuleLoader', @@ -37,14 +44,14 @@ around connect => sub { } 2; }; -sub _perl_command { 'perl', '-' } +sub final_perl_command { shift->perl_command } sub _start_perl { my $self = shift; my $pid = open2( my $foreign_stdout, my $foreign_stdin, - $self->_perl_command(@_), + @{$self->final_perl_command}, ) or die "Failed to run perl at '$_[0]': $!"; return ($foreign_stdin, $foreign_stdout, $pid); } @@ -89,6 +96,7 @@ END $text .= "ENDFAT\n"; $text .= <<'END'; eval $Object::Remote::FatNode::DATA; +die $@ if $@; END $text .= "__END__\n"; return $text;