diff --git a/src/python/pants/bin/remote_pants_runner.py b/src/python/pants/bin/remote_pants_runner.py index e1b563158534..18cc8ac20a15 100644 --- a/src/python/pants/bin/remote_pants_runner.py +++ b/src/python/pants/bin/remote_pants_runner.py @@ -163,13 +163,14 @@ def _connect_and_execute(self, pantsd_handle: PantsDaemonClient.Handle) -> ExitC logger.info(f"rust client: {rust_client}") output = rust_client.execute(port, command, args, modified_env) - logger.info(f"OUTPUT: {output}") + #logger.info(f"OUTPUT: {output}") timeout = global_options.pantsd_pailgun_quit_timeout pantsd_signal_handler = PailgunClientSignalHandler(client, pid=pid, timeout=timeout) with ExceptionSink.trapped_signals(pantsd_signal_handler), STTYSettings.preserved(): + output = rust_client.execute(port, command, args, modified_env) # Execute the command on the pailgun. - return client.execute(self._args[0], self._args[1:], modified_env) + #return client.execute(self._args[0], self._args[1:], modified_env) def _extract_remote_exception(self, pantsd_pid, nailgun_error): """Given a NailgunError, returns a Terminated exception with additional info (where diff --git a/src/rust/engine/nailgun/src/lib.rs b/src/rust/engine/nailgun/src/lib.rs index b8916289523b..1c5c126bba5d 100644 --- a/src/rust/engine/nailgun/src/lib.rs +++ b/src/rust/engine/nailgun/src/lib.rs @@ -93,12 +93,11 @@ async fn handle_client_input(mut stdin_write: mpsc::Sender) -> Resul } pub async fn client_execute(port: u16, command: String, args: Vec, env: Vec<(String, String)>) -> i32 { - use std::time::Duration; + //use std::time::Duration; use nails::execution::{child_channel, Command}; - - let _config = Config::default().heartbeat_frequency(Duration::from_millis(500)); - let _command = Command { + let config = Config::default();/*.heartbeat_frequency(Duration::from_millis(500));*/ + let command = Command { command, args, env, @@ -108,25 +107,30 @@ pub async fn client_execute(port: u16, command: String, args: Vec, env: let (stdio_write, stdio_read) = child_channel::(); let (stdin_write, stdin_read) = child_channel::(); + let output_handler = tokio::spawn(handle_client_output(stdio_read)); + let _input_handler = tokio::spawn(handle_client_input(stdin_write)); let localhost = std::net::Ipv4Addr::new(127, 0, 0, 1); let addr = (localhost, port); - let _stream = TcpStream::connect(addr); - /* - let exit_code = stream.and_then(|socket| { - nails::handle_client_connection( + + let socket = TcpStream::connect(addr).await.unwrap(); + let exit_code: ExitCode = nails::client_handle_connection( config, - socket + socket, command, stdio_write, stdin_read, - ); - }) - .await; - */ + ) + .await + .unwrap(); + + output_handler + .await + .unwrap() + .unwrap(); - let exit_code = 4; - exit_code + //let exit_code = 4; + exit_code.0 } pub struct Server {