Cleaner exit on exception
This commit is contained in:
parent
d6c23172a9
commit
cf83e98162
2 changed files with 10 additions and 1 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue