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:
@@ -11,6 +11,7 @@ use brokerd::container::Podman;
|
||||
use brokerd::memory_port::{MEMORY_WAIT, MemoryPort, Routed};
|
||||
use brokerd::runner::{Refusing, Runtime};
|
||||
use brokerd::serve::{self, ServeError};
|
||||
use bxcore::instance;
|
||||
|
||||
const USAGE: &str = "usage: brokerd serve --config <path> [--accept-break]";
|
||||
/// Where the owner looks when brokerd cannot start: its config, a directory or a socket.
|
||||
@@ -42,6 +43,18 @@ fn main() -> ExitCode {
|
||||
}
|
||||
};
|
||||
|
||||
// One brokerd per home (M5b spec, section 9a). The lock comes before anything is made, the
|
||||
// audit log's own lock included, so a second copy never takes the sockets of the one that
|
||||
// runs. Held until the process ends.
|
||||
let lock_path = cfg.paths.home.join("run/brokerd.lock");
|
||||
let _instance = match instance::lock(&lock_path) {
|
||||
Ok(held) => held,
|
||||
Err(e) => {
|
||||
eprintln!("{}", e.line("brokerd", &lock_path));
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
};
|
||||
|
||||
// Keep the socket paths for the serving notice, before `cfg` is moved into `start`.
|
||||
let broker_path = cfg.broker_socket();
|
||||
let admin_path = cfg.admin_socket();
|
||||
|
||||
Reference in New Issue
Block a user