I'm running into a weird issue with subprocess output
takkuumi opened this issue · comments
Hi, i am using skytable as a subprocess on my desktop application (Tauri application).
it looks like this:
use tauri::{
api::process::{Command, CommandEvent},
Window,
};
// sidecar doc https://tauri.app/v1/guides/building/sidecar
let command = Command::new_sidecar("skyd").expect("Cannot create sidercar");
let (mut rx, mut child) = command
.args(["--noart", "-h", "127.0.0.1", "-p", "19999"])
.current_dir(scoped_dir)
.spawn()
.expect("Failed to spawn skyd");
while let Some(event) = rx.recv().await {
match event {
CommandEvent::Stderr(msg) => {
println!("Stderr:{}", &msg);
window
.emit("stderr", Some(format!("'{}'", msg)))
.expect("failed to emit event");
}
CommandEvent::Stdout(line) => {
println!("Stdout:{}", &line);
window
.emit("message", Some(format!("'{}'", line)))
.expect("failed to emit event");
}
CommandEvent::Terminated(t) => {
println!("{t:?}");
}
_ => unimplemented!(),
};
}
Stderr:[2022-12-02T01:15:28Z INFO skyd] Skytable v0.7.6 | https://github.com/skytable/skytable
Stderr:[2022-12-02T01:15:28Z INFO skyd] Using settings from supplied configuration
Stderr:[2022-12-02T01:15:28Z WARN skyd::config::feedback] CLI warnings:
Stderr: - Running in `user` mode. Set mode to `prod` in production
Stderr:[2022-12-02T01:15:28Z INFO skyd::dbnet] Server started on skyhash://127.0.0.1:19999
When skytable started , i got the ouput from CommandEvent::Stderr
. isn't should be output to CommandEvent::Stdout
?
Skytable uses the log
crate for errors, logs and diagnostic messages. It is common convention to output all diagnostic messages and other such output to stderr
instead of stdout
1
However, since the server doesn't have any "actual output" at this point, it doesn't matter where the outputs are directed. If you're using stderr
to check for errors, consider checking the exit code instead.
That being said, it makes sense to be able to customize where the logs are output through configuration modes.
thx, i will close it