A library for writing host-specific, single-binary configuration management and deployment tools
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
828 B

use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use symbols::Symbol;
pub struct ReloadService<'a> {
service: &'a str,
command_runner: &'a CommandRunner
}
impl<'a> ReloadService<'a> {
pub fn new(service: &'a str, command_runner: &'a CommandRunner) -> Self {
ReloadService {
service: service,
command_runner: command_runner
}
}
}
impl<'a> Symbol for ReloadService<'a> {
fn target_reached(&self) -> Result<bool, Box<Error>> {
Ok(true)
}
fn execute(&self) -> Result<(), Box<Error>> {
try!(self.command_runner.run_with_args("systemctl", &["reload-or-restart", self.service]));
Ok(())
}
}
impl<'a> fmt::Display for ReloadService<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error>{
write!(f, "Reload service {}", self.service)
}
}