use Object::Remote::ModuleSender;
use Object::Remote::Handle;
use Object::Remote::Future;
-use Object::Remote::Logging qw( :log );
+use Object::Remote::Logging qw( :log :dlog );
use Scalar::Util qw(blessed);
use Moo::Role;
has perl_command => (is => 'lazy');
-sub _build_perl_command { [ 'perl', '-' ] }
+#TODO convert nice value into optional feature enabled by
+#setting value of attribute
+#ulimit of ~500 megs of v-ram
+#TODO only works with ssh with quotes but only works locally
+#with out quotes
+sub _build_perl_command { [ 'sh', '-c', '"ulimit -v 500000; nice -n 15 perl -"' ] }
+#sub _build_perl_command { [ 'perl', '-' ] }
around connect => sub {
my ($orig, $self) = (shift, shift);
sub _start_perl {
my $self = shift;
+ Dlog_debug { "invoking connection to perl interpreter using command line: $_" } @{$self->final_perl_command};
my $pid = open2(
my $foreign_stdout,
my $foreign_stdin,
@{$self->final_perl_command},
) or die "Failed to run perl at '$_[0]': $!";
+ Dlog_trace { "Connection to remote side successful; remote stdin and stdout: $_" } [ $foreign_stdin, $foreign_stdout ];
return ($foreign_stdin, $foreign_stdout, $pid);
}
+#TODO open2() forks off a child and I have not been able to locate
+#a mechanism for reaping dead children so they don't become zombies
sub _open2_for {
my $self = shift;
my ($foreign_stdin, $foreign_stdout, $pid) = $self->_start_perl(@_);
my $to_send = $self->fatnode_text;
+ log_debug { my $len = length($to_send); "Sending contents of fat node to remote node; size is '$len' characters" };
Object::Remote->current_loop
->watch_io(
handle => $foreign_stdin,
on_write_ready => sub {
- my $len = syswrite($foreign_stdin, $to_send, 4096);
+ my $len = syswrite($foreign_stdin, $to_send, 32768);
if (defined $len) {
substr($to_send, 0, $len) = '';
}
# if the stdin went away, we'll never get Shere
# so it's not a big deal to simply give up on !defined
if (!defined($len) or 0 == length($to_send)) {
+ log_trace { "Got EOF or error when writing fatnode data to filehandle, unwatching it" };
Object::Remote->current_loop
->unwatch_io(
handle => $foreign_stdin,
on_write_ready => 1
);
+ } else {
+ log_trace { "Sent $len bytes of fatnode data to remote side" };
}
}
);