X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=blobdiff_plain;f=guardian;h=d3f7de0ea0c62d3965ce2b7266a57828fb2be1f6;hp=2326684ad5935c79950941269ec3c9f0fff1e804;hb=ba734c53cc0f9a01e8c077065bc9949c03dc6716;hpb=a9ef502cf10ed2d4b212dc9b782a50d85089a509 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. #