pub enum RestartPolicy {
Never,
Always {
delay_secs: Option<u32>,
},
OnFailure {
delay_secs: Option<u32>,
},
OnSuccess {
delay_secs: Option<u32>,
},
}Expand description
Represents the restart policy for a service.
This enum provides a cross-platform abstraction for service restart behavior with a set of simple options that cover most service managers.
For most service cases you likely want a restart-on-failure policy, so this is the default.
Each service manager supports different levels of granularity:
- Systemd (Linux): supports all variants natively
- Launchd (macOS): supports Never, Always, OnFailure (approximated), and OnSuccess via KeepAlive dictionary
- WinSW (Windows): supports Never, Always, and OnFailure; OnSuccess falls back to Always with a warning
- OpenRC/rc.d/sc.exe: limited or no restart support as of yet
When a platform doesn’t support a specific policy, the implementation will fall back to the closest approximation and log a warning.
In the case where you need a restart policy that is very specific to a particular service
manager, you should instantiate that service manager directly, rather than using the generic
ServiceManager trait.
Variants§
Never
Never restart the service
Always
Always restart the service regardless of exit status.
The optional delay specifies seconds to wait before restarting.
OnFailure
Restart the service only when it exits with a non-zero status.
The optional delay specifies seconds to wait before restarting.
OnSuccess
Restart the service only when it exits with a zero status (success).
The optional delay specifies seconds to wait before restarting.
Trait Implementations§
Source§impl Clone for RestartPolicy
impl Clone for RestartPolicy
Source§fn clone(&self) -> RestartPolicy
fn clone(&self) -> RestartPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RestartPolicy
impl Debug for RestartPolicy
Source§impl Default for RestartPolicy
impl Default for RestartPolicy
Source§impl Hash for RestartPolicy
impl Hash for RestartPolicy
Source§impl PartialEq for RestartPolicy
impl PartialEq for RestartPolicy
impl Copy for RestartPolicy
impl Eq for RestartPolicy
impl StructuralPartialEq for RestartPolicy
Auto Trait Implementations§
impl Freeze for RestartPolicy
impl RefUnwindSafe for RestartPolicy
impl Send for RestartPolicy
impl Sync for RestartPolicy
impl Unpin for RestartPolicy
impl UnwindSafe for RestartPolicy
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
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.