@@ -9,8 +9,7 @@ use crate::config;
99use crate :: gdata;
1010use crate :: imds;
1111use crate :: util:: {
12- interruptible_sleep, is_service_running, service_restart, service_start,
13- SystemdError ,
12+ interruptible_sleep, is_service_running, service_restart, service_start, SystemdError ,
1413} ;
1514use crate :: { enclave, enclave:: P11neEnclave } ;
1615use log:: { debug, error, info, warn} ;
@@ -43,6 +42,7 @@ pub struct Agent {
4342
4443#[ derive( Debug , Hash , Eq , PartialEq ) ]
4544pub enum PostSyncAction {
45+ RestartHttpd ,
4646 RestartNginx ,
4747}
4848
@@ -162,15 +162,18 @@ impl PostSyncAction {
162162 options. sync_interval_secs
163163 ) ;
164164 match self {
165- Self :: RestartNginx => Self :: restart_nginx ( options. reload_wait_ms ) ,
165+ Self :: RestartNginx => Self :: restart_webserver ( "nginx.service" , options. reload_wait_ms ) ,
166+ Self :: RestartHttpd => Self :: restart_webserver ( "httpd.service" , options. reload_wait_ms ) ,
166167 }
167168 }
168169
169- fn restart_nginx ( wait_ms : u64 ) {
170- info ! ( "Restarting NGINX." ) ;
170+ fn restart_webserver ( service_name : & str , wait_ms : u64 ) {
171+ info ! ( "Restarting {}." , service_name ) ;
171172
172- if let Ok ( pid) = is_service_running ( "nginx.service" ) {
173+ if let Ok ( pid) = is_service_running ( service_name ) {
173174 debug ! ( "Sending SIGWINCH to PID={}" , pid) ;
175+ //http://nginx.org/en/docs/control.html
176+ //https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
174177 signal:: kill ( unistd:: Pid :: from_raw ( pid) , signal:: Signal :: SIGWINCH ) . unwrap_or_else (
175178 |err| {
176179 error ! ( "Error sending SIGWINCH: {:?}" , err) ;
@@ -179,11 +182,11 @@ impl PostSyncAction {
179182
180183 std:: thread:: sleep ( Duration :: from_millis ( wait_ms) ) ;
181184 } else {
182- info ! ( "NGINX service is not running" ) ;
185+ info ! ( "{} service is not running" , service_name ) ;
183186 }
184187
185- service_restart ( "nginx.service" ) . unwrap_or_else ( |err| {
186- error ! ( "Unable to restart NGINX : {:?}" , err) ;
188+ service_restart ( service_name ) . unwrap_or_else ( |err| {
189+ error ! ( "Unable to restart {} : {:?}" , service_name , err) ;
187190 } ) ;
188191 }
189- }
192+ }
0 commit comments