X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTak%2FConnectorService.pm;h=15e39bf273a1005a43ac5e549d2b5adbd053190a;hb=8facab5f2e83e16470b817e2f06891f508bf50ec;hp=a3a3caa3cc638b2e20124c0ccc876dd50e8a0eca;hpb=7b71b06eb809e6fbf7c5ca24a54ca40d098465a8;p=scpubgit%2FTak.git diff --git a/lib/Tak/ConnectorService.pm b/lib/Tak/ConnectorService.pm index a3a3caa..15e39bf 100644 --- a/lib/Tak/ConnectorService.pm +++ b/lib/Tak/ConnectorService.pm @@ -6,6 +6,7 @@ use Tak::Router; use Tak::Client; use Tak::ConnectionService; use Net::OpenSSH; +use Tak::STDIONode; use Moo; with 'Tak::Role::Service'; @@ -16,12 +17,16 @@ has ssh => (is => 'ro', default => sub { {} }); sub handle_create { my ($self, $on, %args) = @_; + die [ mistake => "No target supplied to create" ] unless $on; my $log_level = $args{log_level}||'info'; my ($kid_in, $kid_out, $kid_pid) = $self->_open($on, $log_level); - $kid_in->print(io('maint/mk-fat |')->all, "__END__\n"); + $kid_in->print($Tak::STDIONode::DATA, "__END__\n") unless $on eq '-'; + # Need to get a handshake to indicate STDIOSetup has finished + # messing around with file descriptors, otherwise we can severely + # confuse things by sending before the dup. my $up = <$kid_out>; die [ failure => "Garbled response from child: $up" ] - unless $up eq "UP\n"; + unless $up eq "Ssyshere\n"; my $connection = Tak::ConnectionService->new( read_fh => $kid_out, write_fh => $kid_in, listening_service => Tak::Router->new @@ -30,7 +35,7 @@ sub handle_create { # actually, we should register with a monotonic id and # stash the pid elsewhere. but meh for now. my $pid = $client->do(meta => 'pid'); - my $name = ($on||'|').':'.$pid; + my $name = $on.':'.$pid; my $conn_router = Tak::Router->new; $conn_router->register(local => $connection->receiver->service); $conn_router->register(remote => $connection); @@ -40,8 +45,8 @@ sub handle_create { sub _open { my ($self, $on, @args) = @_; - unless ($on) { - my $kid_pid = IPC::Open2::open2(my $kid_out, my $kid_in, $^X, '-', '-', @args) + if ($on eq '-') { + my $kid_pid = IPC::Open2::open2(my $kid_out, my $kid_in, 'tak-stdio-node', '-', @args) or die "Couldn't open2 child: $!"; return ($kid_in, $kid_out, $kid_pid); }