diff --git a/bin/loganinc b/bin/loganinc index 97c0930..3e2f58d 100755 --- a/bin/loganinc +++ b/bin/loganinc @@ -12,4 +12,10 @@ opts[:server] = if ARGV[1] end 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 diff --git a/lib/logan/inc/main.rb b/lib/logan/inc/main.rb index 2c43e67..2921283 100644 --- a/lib/logan/inc/main.rb +++ b/lib/logan/inc/main.rb @@ -51,6 +51,9 @@ module LogAn::Inc @serv = LogAn::Inc::Server.new :sock => TCPServer.new( *@conf[:server]), :config => @conf[:inc] # Shutdown on signals @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 # Will be called at exit. Will close all opened BDB::Env