dude fuck this
This commit is contained in:
parent
b64b0c1cf0
commit
f96ab858c7
1 changed files with 11 additions and 10 deletions
|
|
@ -7,7 +7,8 @@ use crate::commands::argument::{ArgumentSpec, ParsedArguments};
|
|||
use async_trait::async_trait;
|
||||
use std::io::{BufRead, BufReader, Read};
|
||||
use std::process::{Child, Command as SysCommand, Stdio};
|
||||
use std::sync::Arc;
|
||||
use std::process::{ChildStderr, ChildStdout};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::task;
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ impl Command for DeployCommand {
|
|||
|
||||
// Spawn cargo run --release in a separate blocking task
|
||||
let running_arc = self.running.clone();
|
||||
let cargo_task = task::spawn_blocking(move || {
|
||||
let cargo_task = task::spawn_blocking(async move || {
|
||||
let mut cargo_child = match SysCommand::new("cargo")
|
||||
.arg("run")
|
||||
.arg("--release")
|
||||
|
|
@ -118,26 +119,26 @@ impl Command for DeployCommand {
|
|||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let cargo_stdout: ChildStdout;
|
||||
let cargo_stderr: ChildStderr;
|
||||
// Save the child handle for later killing
|
||||
{
|
||||
let mut running = running_arc.blocking_lock();
|
||||
*running = Some(cargo_child.try_clone().unwrap());
|
||||
cargo_stdout = cargo_child.stdout.take().unwrap();
|
||||
cargo_stderr = cargo_child.stderr.take().unwrap();
|
||||
*running = Some(cargo_child);
|
||||
}
|
||||
|
||||
let cargo_stdout = cargo_child.stdout.take().unwrap();
|
||||
let cargo_stderr = cargo_child.stderr.take().unwrap();
|
||||
|
||||
// stdout handler
|
||||
let client_clone_stdout = client_clone.clone();
|
||||
let found_connected_cargo_stdout = found_connected_cargo.clone();
|
||||
let stdout_handle = std::thread::spawn(move || {
|
||||
let stdout_handle = std::thread::spawn(async move || {
|
||||
let reader = BufReader::new(cargo_stdout);
|
||||
for line in reader.lines() {
|
||||
match line {
|
||||
Ok(l) => {
|
||||
let msg = format!("cargo: {}", l);
|
||||
let _ = client_clone_stdout.message(msg);
|
||||
let _ = client_clone_stdout.message(msg).await;
|
||||
if l.contains("[CONNECTED]") {
|
||||
let mut found = found_connected_cargo_stdout.blocking_lock();
|
||||
*found = true;
|
||||
|
|
@ -167,7 +168,7 @@ impl Command for DeployCommand {
|
|||
let _ = stdout_handle.join();
|
||||
let _ = stderr_handle.join();
|
||||
|
||||
let _ = cargo_child.wait();
|
||||
//let _ = cargo_child.wait();
|
||||
});
|
||||
|
||||
// Wait for [CONNECTED] from cargo run --release
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue