pub struct PidFile {
pub pid: u32,
pub addr: Option<String>,
}Expand description
What a pidfile records: the process, and where it listens.
Fields§
§pid: u32The process id.
addr: Option<String>The address it bound, when it announced one.
Implementations§
Source§impl PidFile
impl PidFile
Sourcepub fn listening(pid: u32, addr: impl Into<String>) -> Self
pub fn listening(pid: u32, addr: impl Into<String>) -> Self
A record for a process listening on addr.
Sourcepub fn to_text(&self) -> String
pub fn to_text(&self) -> String
The two-line text form: the pid, then the address (when known).
Deliberately not JSON: cat coordinator.pid and kill $(head -1 …)
are things operators do, and a pidfile that needs a parser to read
is a pidfile that stops being useful the moment the CLI is what is
broken.
Sourcepub fn parse(text: &str) -> Option<Self>
pub fn parse(text: &str) -> Option<Self>
Parses the text form, ignoring anything past the second line.
Sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Whether the recorded process is still alive.
A kill(pid, 0) probe: it answers “is there a process with this id
that I could signal”, which is exactly the question astrs status
and astrs down ask. It cannot tell a recycled pid apart from the
original, which is why crate::command::cluster confirms a
coordinator by greeting it rather than by this alone.
Trait Implementations§
impl Eq for PidFile
impl StructuralPartialEq for PidFile
Auto Trait Implementations§
impl Freeze for PidFile
impl RefUnwindSafe for PidFile
impl Send for PidFile
impl Sync for PidFile
impl Unpin for PidFile
impl UnsafeUnpin for PidFile
impl UnwindSafe for PidFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more