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.

34 lines
740 B

7 years ago
  1. use std::error::Error;
  2. use std::fmt;
  3. use command_runner::CommandRunner;
  4. use symbols::Symbol;
  5. pub struct NginxReload<'a> {
  6. command_runner: &'a CommandRunner,
  7. }
  8. impl<'a> NginxReload<'a> {
  9. pub fn new(command_runner: &'a CommandRunner) -> Self {
  10. NginxReload {
  11. command_runner: command_runner
  12. }
  13. }
  14. }
  15. impl<'a> Symbol for NginxReload<'a> {
  16. fn target_reached(&self) -> Result<bool, Box<Error>> {
  17. Ok(true)
  18. }
  19. fn execute(&self) -> Result<(), Box<Error>> {
  20. try!(self.command_runner.run_with_args("systemctl", &["reload-or-restart", "nginx"]));
  21. Ok(())
  22. }
  23. }
  24. impl<'a> fmt::Display for NginxReload<'a> {
  25. fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error>{
  26. write!(f, "Reload nginx server")
  27. }
  28. }