aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2022-12-28 21:39:11 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2022-12-28 21:39:11 +0100
commit1d6300d44aa05ab35fe0a85caf5f68c6956d17c5 (patch)
tree4d0ca321ac1d22188f2bd99dafe33f87680dde41 /src
parent63d6f565de29c0f45804242a963fe41a24a86468 (diff)
void process output until terminal is ready
Diffstat (limited to 'src')
-rw-r--r--src/main.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 977db28..5e978d4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,15 @@
use anyhow::bail;
-use std::fs;
-use std::io::Write;
+use std::fs::{self, File};
+use std::io::{self, Write};
+use std::os::fd::AsFd;
use std::process::Command;
use std::thread;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
+fn null() -> anyhow::Result<File> {
+ Ok(File::open("/dev/null")?)
+}
+
fn start() -> anyhow::Result<()> {
let mut stdout = StandardStream::stdout(ColorChoice::Always);
@@ -22,13 +27,20 @@ fn start() -> anyhow::Result<()> {
continue;
}
- match Command::new(service.path()).spawn() {
+ let mut cmd = Command::new(service.path());
+ cmd.stderr(null()?).stdin(null()?).stdout(null()?);
+
+ match cmd.spawn() {
Ok(_) => {
stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green)))?;
writeln!(&mut stdout, "[ OK ] Starting {}", service_name)?;
stdout.reset()?;
stdout.flush()?;
+
+ cmd.stderr(io::stderr().as_fd().try_clone_to_owned()?);
+ cmd.stdin(io::stdin().as_fd().try_clone_to_owned()?);
+ cmd.stdout(io::stdout().as_fd().try_clone_to_owned()?);
}
Err(e) => {
stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red)))?;