Cleaner exit on exception

This commit is contained in:
Denis Knauf 2010-03-29 19:16:27 +02:00
parent d6c23172a9
commit cf83e98162
2 changed files with 10 additions and 1 deletions

View file

@ -12,4 +12,10 @@ opts[:server] = if ARGV[1]
end end
opts[:server][1] = opts[:server][1].to_i opts[:server][1] = opts[:server][1].to_i
LogAn::Inc::Main.main *opts logan = LogAn::Inc::Main.new *opts
begin
logan.main
rescue Object
logan.at_exit
raise $!
end

View file

@ -51,6 +51,9 @@ module LogAn::Inc
@serv = LogAn::Inc::Server.new :sock => TCPServer.new( *@conf[:server]), :config => @conf[:inc] @serv = LogAn::Inc::Server.new :sock => TCPServer.new( *@conf[:server]), :config => @conf[:inc]
# Shutdown on signals # Shutdown on signals
@sigs[:INT] = @sigs[:TERM] = method( :shutdown) @sigs[:INT] = @sigs[:TERM] = method( :shutdown)
rescue Object
# It's better to close everything, because BDB doesn't like unexpected exits
self.at_exit
end end
# Will be called at exit. Will close all opened BDB::Env # Will be called at exit. Will close all opened BDB::Env