--no-server parameter to avoid server ipc occupied by ui (#9272)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2024-09-06 14:43:38 +08:00
committed by GitHub
parent aa3402b44a
commit f0ca4b9fee
5 changed files with 33 additions and 18 deletions

View File

@@ -39,6 +39,7 @@ pub fn core_main() -> Option<Vec<String>> {
let mut _is_run_as_system = false;
let mut _is_quick_support = false;
let mut _is_flutter_invoke_new_connection = false;
let mut no_server = false;
let mut arg_exe = Default::default();
for arg in std::env::args() {
if i == 0 {
@@ -62,6 +63,8 @@ pub fn core_main() -> Option<Vec<String>> {
_is_run_as_system = true;
} else if arg == "--quick_support" {
_is_quick_support = true;
} else if arg == "--no-server" {
no_server = true;
} else {
args.push(arg);
}
@@ -134,6 +137,7 @@ pub fn core_main() -> Option<Vec<String>> {
}
}
hbb_common::init_log(false, &log_name);
log::info!("main start args: {:?}, env: {:?}", args, std::env::args());
// linux uni (url) go here.
#[cfg(all(target_os = "linux", feature = "flutter"))]
@@ -161,9 +165,8 @@ pub fn core_main() -> Option<Vec<String>> {
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
init_plugins(&args);
log::info!("main start args:{:?}", args);
if args.is_empty() || crate::common::is_empty_uni_link(&args[0]) {
std::thread::spawn(move || crate::start_server(false));
std::thread::spawn(move || crate::start_server(false, no_server));
} else {
#[cfg(windows)]
{
@@ -279,11 +282,11 @@ pub fn core_main() -> Option<Vec<String>> {
crate::privacy_mode::restore_reg_connectivity(true);
#[cfg(any(target_os = "linux", target_os = "windows"))]
{
crate::start_server(true);
crate::start_server(true, false);
}
#[cfg(target_os = "macos")]
{
let handler = std::thread::spawn(move || crate::start_server(true));
let handler = std::thread::spawn(move || crate::start_server(true, false));
crate::tray::start_tray();
// prevent server exit when encountering errors from tray
hbb_common::allow_err!(handler.join());