alarm() in fatnode is now set to value of connection timeout and is always used even...
[scpubgit/Object-Remote.git] / lib / Object / Remote / Node.pm
CommitLineData
eee9a548 1package Object::Remote::Node;
2
3use strictures 1;
4use Object::Remote::Connector::STDIO;
9031635d 5use Object::Remote::Logging qw(:log :dlog);
c824fdf3 6use Object::Remote::WatchDog;
eee9a548 7use Object::Remote;
8use CPS::Future;
9
10sub run {
c824fdf3 11 my ($class, %args) = @_;
9031635d 12 log_trace { "run() has been invoked on remote node" };
8faf2a28 13
eee9a548 14 my $c = Object::Remote::Connector::STDIO->new->connect;
c824fdf3 15
eee9a548 16 $c->register_class_call_handler;
17
eee9a548 18 my $loop = Object::Remote->current_loop;
c824fdf3 19
9d64d2d9 20 $c->on_close->on_ready(sub {
21 log_info { "Node connection with call handler has closed" };
22 $loop->want_stop
23 });
eee9a548 24
9031635d 25 Dlog_trace { "Node is sending 'Shere' to $_" } $c->send_to_fh;
eee9a548 26 print { $c->send_to_fh } "Shere\n";
27
9d64d2d9 28 log_debug { "Node is going to start the run loop" };
8faf2a28 29 if ($args{watchdog_timeout}) {
30 Object::Remote::WatchDog->new(timeout => $args{watchdog_timeout});
31 } else {
32 #reset connection watchdog from the fatnode
33 alarm(0);
34 }
eee9a548 35 $loop->want_run;
36 $loop->run_while_wanted;
9d64d2d9 37 log_debug { "Run loop invocation in node has completed" };
eee9a548 38}
39
401;