$SIG{INT} = \&Shutdown;
$SIG{TERM} = \&Shutdown;
$SIG{QUIT} = \&Shutdown;
+ $SIG{HUP} = \&Reload;
}
#
foreach my $worker (@running_workers) {
# Send the worker the "KILL" signal and detach the
# thread so perl can do an automatically clean-up.
- $worker->kill('KILL')->detach();
+ $worker->kill('KILL');
}
}
+#
+## 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.
#
# Remove socket file on exit.
&Guardian::Socket::RemoveSocketFile();
+ # Sleep for one second to give perl some
+ # time to proper clean up everything before
+ # exiting.
+ sleep(1);
+
# Exit guardian.
exit;
}