aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-06-13 11:02:37 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-06-13 11:02:37 +0100
commitb22cbc87927553f6dbb5754281e95fe9bad2eed1 (patch)
tree5575791fe84492648a8cc92433c267815056507a /bin
parent495c44445642cfae8f23fadde299ad5307f5be58 (diff)
* Tidied up mauveserver to handle HUP restarts
* Added HTML santizing to the alert class, so bad HTML is stripped as part of processing. * Alert#cleared? now means "not raised" * Better error handling in the Timer class, making sure that the timer never gets permanently frozen. * Moved notification and packet buffers to the Server class, meaning that if the Processor or Notifier threads crash, we don't lose all the items waiting to be processed/notified. * XMPP/Email Alerts now use templates, instead of instance methods. * Emails now get sent as multipart with HTML to allow detail fields to be shown as nature intended.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mauveserver26
1 files changed, 16 insertions, 10 deletions
diff --git a/bin/mauveserver b/bin/mauveserver
index 57a2299..baeee75 100755
--- a/bin/mauveserver
+++ b/bin/mauveserver
@@ -9,12 +9,9 @@ rescue SyntaxError => no_blocks_with_procs
end
require 'mauve/configuration'
-include Mauve
configuration_file = ARGV[0]
-
configuration_file = [".", "/etc/mauvealert/"].find{|d| File.file?(File.join(d,"mauveserver.conf")) } if configuration_file.nil?
-
configuration_file = File.expand_path(configuration_file)
unless File.file?(configuration_file)
@@ -22,26 +19,35 @@ unless File.file?(configuration_file)
Kernel.exit 1
end
-Configuration.current = ConfigurationBuilder.load(configuration_file)
+Mauve::Configuration.current = Mauve::ConfigurationBuilder.load(configuration_file)
%w(HUP).each do |sig|
trap("HUP") do
# this blows up if you do it twice in quick succession, but don't really
# care about that case as it's only for log rotation.
- Configuration.current.logger.warn "#{sig} signal received. Restarting."
- Configuration.current.server.stop
+ Mauve::Server.instance.logger.warn "#{sig} signal received. Stopping."
+ Mauve::Server.instance.stop
+
#
# Reload configuration
#
- Configuration.current = ConfigurationBuilder.load(configuration_file)
- Configuration.current.server.start
+ Mauve::Server.instance.logger.warn "Restarting."
+
+ begin
+ new_config = Mauve::ConfigurationBuilder.load(configuration_file)
+ Mauve::Configuration.current = new_config
+ rescue BuildException => ex
+ Mauve::Server.instance.logger.warn "Reconfiguration failed: #{ex}. Sticking with old one."
+ end
+ Mauve::Server.instance.logger.warn "Restarting."
+ Mauve::Server.instance.start
end
end
%w(QUIT TERM INT).each do |sig|
trap(sig) do
- Configuration.current.logger.warn "#{sig} signal received. Exiting."
- Configuration.current.server.stop
+ Mauve::Server.instance.logger.warn "#{sig} signal received. Stopping."
+ Mauve::Server.instance.stop
exit 0
end
end