Skip to content

Commit 0bf9de8

Browse files
committed
also check --server in loop
1 parent 77f1c7e commit 0bf9de8

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/platform/macos.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -514,27 +514,31 @@ pub fn start_os_service() {
514514
if server.is_none() {
515515
server = get_server_start_time(&mut sys, &path);
516516
}
517-
if let Some((start_time, pid)) = server {
518-
if my_start_time <= start_time + 1 {
519-
log::error!(
517+
let Some((start_time, pid)) = server else {
518+
log::error!(
519+
"Agent not started yet, please restart --server first to make delegate work",
520+
);
521+
std::process::exit(-1);
522+
};
523+
if my_start_time <= start_time + 1 {
524+
log::error!(
520525
"Agent start later, {my_start_time} vs {start_time}, please start --server first to make delegate work",
521526
);
522-
std::process::exit(-1);
523-
}
524-
// only refresh this pid and check if valid, no need to refresh all processes since refreshing all is expensive, about 10ms on my machine
525-
if !sys.refresh_process_specifics(pid, ProcessRefreshKind::new()) {
526-
server = None;
527-
continue;
528-
}
529-
if let Some(p) = sys.process(pid.into()) {
530-
if let Some(p) = get_server_start_time_of(p, &path) {
531-
server = Some((p, pid));
532-
} else {
533-
server = None;
534-
}
527+
std::process::exit(-1);
528+
}
529+
// only refresh this pid and check if valid, no need to refresh all processes since refreshing all is expensive, about 10ms on my machine
530+
if !sys.refresh_process_specifics(pid, ProcessRefreshKind::new()) {
531+
server = None;
532+
continue;
533+
}
534+
if let Some(p) = sys.process(pid.into()) {
535+
if let Some(p) = get_server_start_time_of(p, &path) {
536+
server = Some((p, pid));
535537
} else {
536538
server = None;
537539
}
540+
} else {
541+
server = None;
538542
}
539543
});
540544

0 commit comments

Comments
 (0)