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=090f13295c97edb32752cc46b9a58f89297a4334;hp=2b9fa59ed879cb65a1a256779d72264a6f43f74d;hb=ffc9934e59f8c485311c960b867d61aa4276893a;hpb=8f43bcd9596b298f867bc3daf5b207d774973af7 diff --git a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm index 2b9fa59..090f132 100644 --- a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm +++ b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm @@ -1,6 +1,5 @@ package Object::Remote::Role::Connector::PerlInterpreter; -use IPC::Open2; use IPC::Open3; use IO::Handle; use Symbol; @@ -17,6 +16,7 @@ has module_sender => (is => 'lazy'); has ulimit => ( is => 'ro'); has nice => ( is => 'ro'); has watchdog_timeout => ( is => 'ro', required => 1, default => sub { undef }); +has forward_env => (is => 'ro', required => 1, builder => 1); has perl_command => (is => 'lazy'); has pid => (is => 'rwp'); has connection_id => (is => 'rwp'); @@ -34,6 +34,7 @@ sub _build_module_sender { return $hook ? $hook->sender : Object::Remote::ModuleSender->new; } +#FIXME by policy object-remote does not invoke a shell sub _build_perl_command { my ($self) = @_; my $nice = $self->nice; @@ -59,6 +60,14 @@ sub _build_perl_command { return [ 'bash', '-c', $shell_code ]; } +sub _build_forward_env { + return [qw( + OBJECT_REMOTE_PERL_BIN + OBJECT_REMOTE_LOG_LEVEL OBJECT_REMOTE_LOG_FORMAT OBJECT_REMOTE_LOG_SELECTIONS + OBJECT_REMOTE_LOG_FORWARDING + )]; +} + around connect => sub { my ($orig, $self) = (shift, shift); my $f = $self->$start::start($orig => @_); @@ -227,6 +236,13 @@ sub fatnode_text { $text .= "my \$WATCHDOG_TIMEOUT = undef;\n"; } + $text .= $self->_create_env_forward(@{$self->forward_env}); + + #Action at a distance but at least it's not spooky - the logging + #system needs to know if a node is remote but there is a period + #during init where the remote connection information has not been + #setup on the remote side yet so this flag allows a graceful + #degredation to happen $text .= '$Object::Remote::FatNode::REMOTE_NODE = "1";' . "\n"; $text .= <<'END'; @@ -244,4 +260,24 @@ END return $text; } +sub _create_env_forward { + my ($self, @env_names) = @_; + my $code = ''; + + foreach my $name (@env_names) { + next unless exists $ENV{$name}; + my $value = $ENV{$name}; + $name =~ s/'/\\'/g; + if(defined($value)) { + $value =~ s/'/\\'/g; + $value = "'$value'"; + } else { + $value = 'undef'; + } + $code .= "\$ENV{'$name'} = $value;\n"; + } + + return $code; +} + 1;