Commit | Line | Data |
---|---|---|
eee9a548 | 1 | package Object::Remote::Node; |
2 | ||
3 | use strictures 1; | |
4 | use Object::Remote::Connector::STDIO; | |
07105aca | 5 | use Object::Remote::Logging qw(:log :dlog); |
69aaad21 | 6 | use Object::Remote::WatchDog; |
eee9a548 | 7 | use Object::Remote; |
8 | use CPS::Future; | |
9 | ||
10 | sub run { | |
69aaad21 | 11 | my ($class, %args) = @_; |
07105aca | 12 | log_trace { "run() has been invoked on remote node" }; |
69aaad21 | 13 | |
14 | if ($args{watchdog_timeout}) { | |
e5b3f03f | 15 | Object::Remote::WatchDog->new(timeout => $args{watchdog_timeout}); |
69aaad21 | 16 | } |
17 | ||
eee9a548 | 18 | my $c = Object::Remote::Connector::STDIO->new->connect; |
69aaad21 | 19 | |
eee9a548 | 20 | $c->register_class_call_handler; |
21 | ||
eee9a548 | 22 | my $loop = Object::Remote->current_loop; |
69aaad21 | 23 | |
2d81cf18 | 24 | $c->on_close->on_ready(sub { |
25 | log_info { "Node connection with call handler has closed" }; | |
26 | $loop->want_stop | |
27 | }); | |
eee9a548 | 28 | |
07105aca | 29 | Dlog_trace { "Node is sending 'Shere' to $_" } $c->send_to_fh; |
eee9a548 | 30 | print { $c->send_to_fh } "Shere\n"; |
31 | ||
2d81cf18 | 32 | log_debug { "Node is going to start the run loop" }; |
eee9a548 | 33 | $loop->want_run; |
34 | $loop->run_while_wanted; | |
2d81cf18 | 35 | log_debug { "Run loop invocation in node has completed" }; |
eee9a548 | 36 | } |
37 | ||
38 | 1; |