mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-01-11 22:40:32 +00:00
Slightly better error handling for the server
This commit is contained in:
parent
ef461f0440
commit
b85cf31cd1
1 changed files with 18 additions and 4 deletions
|
|
@ -1,4 +1,6 @@
|
|||
use native_windows_gui as nwg;
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
|
@ -17,12 +19,24 @@ impl StremioServer {
|
|||
job.set_extended_limit_info(&mut info).ok();
|
||||
job.assign_current_process().ok();
|
||||
loop {
|
||||
let mut child = Command::new("stremio-runtime")
|
||||
let child = Command::new("./stremio-runtime")
|
||||
.arg("server.js")
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.spawn()
|
||||
.expect("Cannot run the server");
|
||||
child.wait().expect("Cannot wait for the server");
|
||||
.spawn();
|
||||
match child {
|
||||
Ok(mut child) => {
|
||||
// TODO: store somehow last few lines of the child's stdout/stderr instead of just waiting
|
||||
child.wait().expect("Cannot wait for the server");
|
||||
}
|
||||
Err(err) => {
|
||||
nwg::error_message(
|
||||
"Stremio server",
|
||||
format!("Cannot execute stremio-runtime: {}", &err).as_str(),
|
||||
);
|
||||
break;
|
||||
}
|
||||
};
|
||||
// TODO: show error message with the child's stdout/stderr
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
dbg!("Trying to restart the server...");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue