feat: ensure single instance to prevent duplicate daemon and tray icons
This commit is contained in:
parent
88d39b4475
commit
389c58e1fa
2 changed files with 18 additions and 0 deletions
|
|
@ -505,6 +505,15 @@ fn recover_display_env() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
// Ensure single instance to avoid duplicate daemon processes
|
||||||
|
let _listener = match std::os::unix::net::UnixListener::bind("\0vietc-daemon-lock") {
|
||||||
|
Ok(l) => l,
|
||||||
|
Err(_) => {
|
||||||
|
eprintln!("[vietc] Another instance is already running. Exiting.");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
recover_display_env();
|
recover_display_env();
|
||||||
let config_path = config::find_config_path();
|
let config_path = config::find_config_path();
|
||||||
let config = Config::load()?;
|
let config = Config::load()?;
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,15 @@ fn config_path() -> PathBuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// Ensure single instance to avoid duplicate tray icons
|
||||||
|
let _listener = match std::os::unix::net::UnixListener::bind("\0vietc-tray-lock") {
|
||||||
|
Ok(l) => l,
|
||||||
|
Err(_) => {
|
||||||
|
eprintln!("[vietc-tray] Another instance is already running. Exiting.");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
eprintln!("[vietc-tray] Starting");
|
eprintln!("[vietc-tray] Starting");
|
||||||
|
|
||||||
// Start daemon (with password prompt if first launch)
|
// Start daemon (with password prompt if first launch)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue