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:
2026-09-27 19:08:42 -07:00
co-authored by ornith-1.5-35b-a3b
parent fd0437a032
commit 7cbc1d7342
8 changed files with 696 additions and 19 deletions
+12
View File
@@ -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,