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