From: Stefan Schantl Date: Wed, 25 Nov 2015 11:21:34 +0000 (+0100) Subject: Add support to reload the service. X-Git-Tag: 2.0~65 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=ba734c53cc0f9a01e8c077065bc9949c03dc6716;hp=a9ef502cf10ed2d4b212dc9b782a50d85089a509 Add support to reload the service. When sending a "SIGHUP" signal to the guardian process, we now doing a complete reload of the configuration. Signed-off-by: Stefan Schantl --- diff --git a/guardian b/guardian index 2326684..d3f7de0 100644 --- a/guardian +++ b/guardian @@ -265,6 +265,7 @@ sub SignalHandler { $SIG{INT} = \&Shutdown; $SIG{TERM} = \&Shutdown; $SIG{QUIT} = \&Shutdown; + $SIG{HUP} = \&Reload; } # @@ -298,6 +299,27 @@ sub StopWorkers () { } } +# +## Reload function. +# +## This function will get called if the signal handler recieves a "SIGHUP" signal, +## or the reload command will be sent via socket connection. It is responsible for +## reloading all configure options and stopping/starting the worker threads. +# +sub Reload () { + # Stop all running workers. + &StopWorkers(); + + # Re-read configuration file. + %mainsettings = &Guardian::Config::UseConfig($cmdargs{"config"}); + + # Re-generate hash of monitored files. + %monitored_files = &Guardian::Base::GenerateMonitoredFiles(\%mainsettings, \%monitored_files); + + # Restart the worker threads. + &StartWorkers(); +} + # ## Shutdown function. #