refactor macos service for delegate again, remove runme in install service of linux
This commit is contained in:
parent
7c45a68870
commit
137f58a84a
@ -1397,8 +1397,6 @@ pub fn install_service() -> bool {
|
|||||||
Config::set_option("stop-service".into(), "Y".into());
|
Config::set_option("stop-service".into(), "Y".into());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
run_me_with(2);
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_if_stop_service() {
|
fn check_if_stop_service() {
|
||||||
|
@ -500,29 +500,24 @@ pub fn start_os_service() {
|
|||||||
let path =
|
let path =
|
||||||
std::fs::canonicalize(std::env::current_exe().unwrap_or_default()).unwrap_or_default();
|
std::fs::canonicalize(std::env::current_exe().unwrap_or_default()).unwrap_or_default();
|
||||||
let mut server = get_server_start_time(&mut sys, &path);
|
let mut server = get_server_start_time(&mut sys, &path);
|
||||||
|
if server.is_none() {
|
||||||
|
log::error!("Agent not started yet, will restart --service to make delegate work",);
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
let my_start_time = sys
|
let my_start_time = sys
|
||||||
.process((std::process::id() as usize).into())
|
.process((std::process::id() as usize).into())
|
||||||
.map(|p| p.start_time())
|
.map(|p| p.start_time())
|
||||||
.unwrap_or_default() as i64;
|
.unwrap_or_default() as i64;
|
||||||
log::info!("Startime: {my_start_time} vs {:?}", server);
|
log::info!("Startime: {my_start_time} vs {:?}", server);
|
||||||
|
|
||||||
let uname = get_active_username();
|
|
||||||
std::thread::spawn(move || loop {
|
std::thread::spawn(move || loop {
|
||||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
let tmp = get_active_username();
|
|
||||||
// restart my self after login to make sure --server started earlier
|
|
||||||
// so that not forbid user start main window because of delegate caught by --service
|
|
||||||
if uname != tmp {
|
|
||||||
log::info!("Console user changed from {uname} to {tmp}");
|
|
||||||
std::process::exit(-1);
|
|
||||||
}
|
|
||||||
if server.is_none() {
|
if server.is_none() {
|
||||||
server = get_server_start_time(&mut sys, &path);
|
server = get_server_start_time(&mut sys, &path);
|
||||||
}
|
}
|
||||||
if let Some((start_time, pid)) = server {
|
if let Some((start_time, pid)) = server {
|
||||||
if my_start_time <= start_time {
|
if my_start_time <= start_time {
|
||||||
// I tried add delegate (using tao and with its main loop0, but it works in normal mode, but not work as daemon
|
log::error!(
|
||||||
log::info!(
|
|
||||||
"Agent start later, {my_start_time} vs {start_time}, will restart --service to make delegate work",
|
"Agent start later, {my_start_time} vs {start_time}, will restart --service to make delegate work",
|
||||||
);
|
);
|
||||||
std::process::exit(-1);
|
std::process::exit(-1);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<array>
|
<array>
|
||||||
<string>/bin/sh</string>
|
<string>/bin/sh</string>
|
||||||
<string>-c</string>
|
<string>-c</string>
|
||||||
<string>sleep 1.5; /Applications/RustDesk.app/Contents/MacOS/RustDesk --service</string>
|
<string>sleep 3; /Applications/RustDesk.app/Contents/MacOS/RustDesk --service</string>
|
||||||
</array>
|
</array>
|
||||||
<key>RunAtLoad</key>
|
<key>RunAtLoad</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user