pub struct ServiceConfig {
pub name: String,
pub description: String,
pub exec_start: String,
pub working_directory: Option<String>,
pub user: Option<String>,
pub group: Option<String>,
pub restart: Option<String>,
pub restart_sec: Option<u32>,
pub wanted_by: Option<String>,
pub environment: Option<Vec<(String, String)>>,
pub after: Option<Vec<String>>,
pub log_file: Option<String>,
}Expand description
Represents the configuration for a systemd service.
Use ServiceConfig::new to create a basic configuration
and chain builder methods to set optional parameters.
Fields§
§name: StringThe name of the service (e.g., “myapp”). This is used for the .service filename.
description: StringA brief description of the service (e.g., “My Application Service”).
exec_start: StringThe command to execute to start the service (e.g., “/usr/local/bin/myapp –daemon”).
working_directory: Option<String>The working directory for the service process.
user: Option<String>The user to run the service as.
group: Option<String>The group to run the service as.
restart: Option<String>Restart policy (e.g., “no”, “on-success”, “on-failure”, “always”).
restart_sec: Option<u32>Delay (in seconds) before restarting the service.
wanted_by: Option<String>The target to install this service under (usually “multi-user.target”).
environment: Option<Vec<(String, String)>>Environment variables to set for the service (e.g., vec![("RUST_LOG".to_string(), "info".to_string())]).
after: Option<Vec<String>>Services that must be started before this one (e.g., vec!["network.target".to_string()]).
log_file: Option<String>File path to redirect StandardOutput to. StandardError is set to inherit.
Implementations§
Source§impl ServiceConfig
impl ServiceConfig
Sourcepub fn new(name: &str, exec_start: &str, description: &str) -> Self
pub fn new(name: &str, exec_start: &str, description: &str) -> Self
Creates a new ServiceConfig with the essential fields.
All other fields are set to their default values.
Sourcepub fn working_directory(self, dir: &str) -> Self
pub fn working_directory(self, dir: &str) -> Self
Sets the working directory for the service (builder method).
Sourcepub fn restart(self, restart: &str) -> Self
pub fn restart(self, restart: &str) -> Self
Sets the restart policy for the service (builder method).
Sourcepub fn restart_sec(self, sec: u32) -> Self
pub fn restart_sec(self, sec: u32) -> Self
Sets the restart delay (in seconds) for the service (builder method).
Sourcepub fn wanted_by(self, target: &str) -> Self
pub fn wanted_by(self, target: &str) -> Self
Sets the WantedBy target for the service (builder method).
Sourcepub fn environment(self, env: Vec<(String, String)>) -> Self
pub fn environment(self, env: Vec<(String, String)>) -> Self
Sets environment variables for the service (builder method).
Trait Implementations§
Source§impl Clone for ServiceConfig
impl Clone for ServiceConfig
Source§fn clone(&self) -> ServiceConfig
fn clone(&self) -> ServiceConfig
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServiceConfig
impl Debug for ServiceConfig
Auto Trait Implementations§
impl Freeze for ServiceConfig
impl RefUnwindSafe for ServiceConfig
impl Send for ServiceConfig
impl Sync for ServiceConfig
impl Unpin for ServiceConfig
impl UnwindSafe for ServiceConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)