X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FObject%2FRemote%2FNode.pm;h=a790ba8d2543af7f0f67e623f1e061224e16dc33;hb=ae19820130feb4fc48d8e365ce5c3109642d203c;hp=7190359d5c1d03c983da3dd4a41311a0759ea7ca;hpb=eee9a5487590df4c2ead52b01435716afbd23fe5;p=scpubgit%2FObject-Remote.git diff --git a/lib/Object/Remote/Node.pm b/lib/Object/Remote/Node.pm index 7190359..a790ba8 100644 --- a/lib/Object/Remote/Node.pm +++ b/lib/Object/Remote/Node.pm @@ -2,29 +2,39 @@ package Object::Remote::Node; use strictures 1; use Object::Remote::Connector::STDIO; +use Object::Remote::Logging qw(:log :dlog); +use Object::Remote::WatchDog; use Object::Remote; use CPS::Future; sub run { - + my ($class, %args) = @_; + log_trace { "run() has been invoked on remote node" }; + my $c = Object::Remote::Connector::STDIO->new->connect; - + $c->register_class_call_handler; - $c->ready_future->done; - my $loop = Object::Remote->current_loop; + + $c->on_close->on_ready(sub { + log_info { "Node connection with call handler has closed" }; + $loop->want_stop + }); - my $f = CPS::Future->new; - - $f->on_ready(sub { $loop->want_stop }); - - $c->on_close($f); - + Dlog_trace { "Node is sending 'Shere' to $_" } $c->send_to_fh; print { $c->send_to_fh } "Shere\n"; + log_debug { "Node is going to start the run loop" }; + if ($args{watchdog_timeout}) { + Object::Remote::WatchDog->new(timeout => $args{watchdog_timeout}); + } else { + #reset connection watchdog from the fatnode + alarm(0); + } $loop->want_run; $loop->run_while_wanted; + log_debug { "Run loop invocation in node has completed" }; } 1;