]> git.ipfire.org Git - people/stevee/guardian.git/blobdiff - guardian
Add support to reload the service.
[people/stevee/guardian.git] / guardian
index 2326684ad5935c79950941269ec3c9f0fff1e804..d3f7de0ea0c62d3965ce2b7266a57828fb2be1f6 100644 (file)
--- 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.
 #