pub struct SystemdNotifier;Expand description
Systemd notification wrapper
All methods are no-ops if not running under systemd (no NOTIFY_SOCKET).
Implementations§
Source§impl SystemdNotifier
impl SystemdNotifier
Sourcepub fn status(msg: &str)
pub fn status(msg: &str)
Update the status message shown in systemctl status
Sends STATUS=<msg> to systemd. This can be called periodically
to show useful information in the service status.
§Arguments
msg- Status message to display
§Example
// Show current activity
SystemdNotifier::status("Loaded 3 models, serving requests");
SystemdNotifier::status("Processing 42 active connections");Sourcepub fn watchdog()
pub fn watchdog()
Ping the watchdog timer
Sends WATCHDOG=1 to systemd. This should ONLY be called when the
service is healthy. If the service becomes unhealthy, stop pinging
and let systemd restart it after WatchdogSec timeout.
§Important
Only call this when health checks pass. Pinging while unhealthy defeats the purpose of the watchdog.
§Example
if health_check_passed().await {
SystemdNotifier::watchdog();
}
// If health check fails, don't ping - systemd will restartSourcepub fn watchdog_interval() -> Option<Duration>
pub fn watchdog_interval() -> Option<Duration>
Get the watchdog ping interval
Returns the recommended interval for pinging the watchdog, which is
half of the WatchdogSec value configured in the unit file.
§Returns
Some(duration) if watchdog is enabled, None if not configured
or not running under systemd.
§Example
if let Some(interval) = SystemdNotifier::watchdog_interval() {
info!("Watchdog enabled, pinging every {:?}", interval);
// Start watchdog task
} else {
info!("Watchdog not configured");
}Sourcepub fn is_systemd_managed() -> bool
pub fn is_systemd_managed() -> bool
Check if running under systemd management
Returns true if NOTIFY_SOCKET environment variable is set,
indicating the service was started by systemd with notification
support enabled.
Sourcepub fn expected_pid() -> Option<u32>
pub fn expected_pid() -> Option<u32>
Get the PID that systemd expects for notifications
Returns the PID that should be sending notifications. For most
services this is the main PID (returned by getpid()).
Auto Trait Implementations§
impl Freeze for SystemdNotifier
impl RefUnwindSafe for SystemdNotifier
impl Send for SystemdNotifier
impl Sync for SystemdNotifier
impl Unpin for SystemdNotifier
impl UnsafeUnpin for SystemdNotifier
impl UnwindSafe for SystemdNotifier
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request