brokerd, memoryd, gatewayd: a lock file keeps each to one instance
Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
@@ -5,6 +5,7 @@ use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
use std::sync::Arc;
|
||||
|
||||
use bxcore::instance;
|
||||
use memoryd::config::Config;
|
||||
use memoryd::serve;
|
||||
|
||||
@@ -24,6 +25,17 @@ fn main() -> ExitCode {
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
};
|
||||
// One memoryd per home (M5b spec, section 9a). The lock comes before anything under the home
|
||||
// is made or bound, so a second copy never takes the sockets of the one that runs. Held until
|
||||
// the process ends.
|
||||
let lock_path = config.paths.home.join("run/memoryd.lock");
|
||||
let _instance = match instance::lock(&lock_path) {
|
||||
Ok(held) => held,
|
||||
Err(e) => {
|
||||
eprintln!("{}", e.line("memoryd", &lock_path));
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
};
|
||||
let log: serve::Log = Arc::new(|line: &str| eprintln!("{line}"));
|
||||
let running = match serve::start(config, log) {
|
||||
Ok(running) => running,
|
||||
|
||||
Reference in New Issue
Block a user