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.

40 lines
861 B

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