Skip to main content

executable_identity

Function executable_identity 

Source
pub fn executable_identity() -> Option<ExecutableIdentity>
Expand description

What the running executable is, for the lease to record: the path it was started from and the identity of the file at that path. A server outlives its own binary — a rebuild replaces the file under a process that keeps serving the code it loaded hours ago — and nothing about the process itself says so. This is what makes that visible.

None when the executable cannot be located or stat’ed; the lease then carries no claim, and the election’s superseded check makes none either.

use majordomus_cli::lease::executable_identity;
// the process running this example can locate itself, and the file it names is there
let mine = executable_identity().expect("a test binary knows where it is");
assert!(mine.path.is_file());
assert!(mine.replaced().is_none(), "the file that is running has not been replaced");