opt: add join handler to prevent server stopped
This commit is contained in:
parent
220d056760
commit
821f042fd9
@ -158,10 +158,12 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
std::thread::spawn(move || crate::start_server(true));
|
std::thread::spawn(move || crate::start_server(true));
|
||||||
// to-do: for flutter, starting tray not ready yet, or we can reuse sciter's tray implementation.
|
// to-do: for flutter, starting tray not ready yet, or we can reuse sciter's tray implementation.
|
||||||
}
|
}
|
||||||
#[cfg(all(target_os = "linux", feature = "flutter"))]
|
#[cfg(all(target_os = "linux"))]
|
||||||
{
|
{
|
||||||
std::thread::spawn(move || crate::start_server(true));
|
let handler = std::thread::spawn(move || crate::start_server(true));
|
||||||
crate::tray::start_tray(crate::ui_interface::OPTIONS.clone());
|
crate::tray::start_tray(crate::ui_interface::OPTIONS.clone());
|
||||||
|
// revent server exit when encountering errors from tray
|
||||||
|
handler.join();
|
||||||
}
|
}
|
||||||
} else if args[0] == "--import-config" {
|
} else if args[0] == "--import-config" {
|
||||||
if args.len() == 2 {
|
if args.len() == 2 {
|
||||||
|
@ -91,7 +91,6 @@ pub fn start_tray(options: Arc<Mutex<HashMap<String, String>>>) {
|
|||||||
// init gtk context
|
// init gtk context
|
||||||
if let Err(err) = gtk::init() {
|
if let Err(err) = gtk::init() {
|
||||||
error!("Error when starting the tray: {}", err);
|
error!("Error when starting the tray: {}", err);
|
||||||
gtk::main_quit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some(mut appindicator) = get_default_app_indicator() {
|
if let Some(mut appindicator) = get_default_app_indicator() {
|
||||||
@ -116,7 +115,7 @@ pub fn start_tray(options: Arc<Mutex<HashMap<String, String>>>) {
|
|||||||
info!("Setting tray event loop");
|
info!("Setting tray event loop");
|
||||||
gtk::main();
|
gtk::main();
|
||||||
} else {
|
} else {
|
||||||
eprintln!("tray process exit now");
|
error!("Tray process exit now");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user