or /\Q$Config{archname}/ or /\Q$Config{myarchname}/)
), keys %mods;
-#FIXME - encode the env vars in YAML or something similiar and make the
-#env vars that will be forwarded driven by a list
-my $env_pass = '';
-if (defined($ENV{OBJECT_REMOTE_LOG_LEVEL})) {
- my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
- $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";
-}
-if (defined($ENV{OBJECT_REMOTE_LOG_SELECTIONS})) {
- my $selections = $ENV{OBJECT_REMOTE_LOG_SELECTIONS};
- $env_pass .= '$ENV{OBJECT_REMOTE_LOG_SELECTIONS} = "' . $selections . "\";\n";
-}
-if (defined($ENV{OBJECT_REMOTE_LOG_FORWARDING})) {
- my $forwarding = $ENV{OBJECT_REMOTE_LOG_FORWARDING};
- $env_pass .= '$ENV{OBJECT_REMOTE_LOG_FORWARDING} = "' . $forwarding . "\";\n";
-}
-if (defined($ENV{OBJECT_REMOTE_PERL_BIN})) {
- my $perl_bin = $ENV{OBJECT_REMOTE_PERL_BIN};
- $env_pass .= '$ENV{OBJECT_REMOTE_PERL_BIN} = "' . $perl_bin . "\";\n";
-}
-
-
-
my $start = stripspace <<'END_START';
# This chunk of stuff was generated by Object::Remote::FatNode. To find
# the original file's code, look for the end of this BEGIN block or the
map(generate_fatpack_hash('fatpacked_extra', $_), sort map $mods{$_}, @core_non_arch),
);
-our $DATA = join "\n", $start, $env_pass, @segments, $end;
+#print STDERR Dumper(\@segments);
+our $DATA = join "\n", $start, @segments, $end;
1;
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');
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 => @_);
$text .= "my \$WATCHDOG_TIMEOUT = undef;\n";
}
+ $text .= $self->_create_env_forward(@{$self->forward_env});
$text .= '$Object::Remote::FatNode::REMOTE_NODE = "1";' . "\n";
$text .= <<'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;