def self.handle_event(condition)
Thread.new do
begin
metric = self.directory[condition]
unless metric.nil?
watch = metric.watch
watch.mutex.synchronize do
messages = self.log(watch, metric, condition, true)
if condition.notify && self.trigger?(metric, true)
self.notify(condition, messages.last)
end
dest =
if condition.transition
condition.transition
else
metric.destination && metric.destination[true]
end
if dest
watch.move(dest)
end
end
end
rescue Exception => e
message = format("Unhandled exception (%s): %s\n%s",
e.class, e.message, e.backtrace.join("\n"))
applog(nil, :fatal, message)
end
end
end