Inspector added (loganinc --inspector)

This commit is contained in:
Denis Knauf 2010-04-14 11:36:25 +02:00
parent b76953f57d
commit 76a05892db
2 changed files with 14 additions and 2 deletions

View file

@ -4,6 +4,7 @@ require 'logan'
require 'logan/inc'
opts = {}
opts[:inspector] = ARGV[0] == '--inspector' ? ARGV.shift : false
opts[:server] = if ARGV[1]
ARGV
elsif ARGV[0]
@ -14,6 +15,17 @@ opts[:server][1] = opts[:server][1].to_i
logan = LogAn::Inc::Main.new opts
begin
logan.instance_eval do
@inspector_server = UNIXServer.new 'loganinc.inspector.sock'
Thread.new do
loop do
sock = @inspector_server.accept
sock.each_line do |line|
sock.puts eval( line).inspect
end
end
end
end if opts[:inspector]
logan.main
rescue Object
logan.at_exit

View file

@ -30,10 +30,10 @@ module LogAn
AutoKeyConvertHash.new(
@env[ 'rotates.db', :type => SBDB::Btree, :flags => SBDB::CREATE | SBDB::AUTO_COMMIT],
lambda {|key| [key.to_i].pack 'N' }) {|key| Time.at key.unpack( 'N') },
lambda {|val| String === val ? val : val.raw } {|val| val && UUIDTools::UUID.parse_raw( val) }
lambda {|val| String === val ? val : val.raw }) {|val| val && UUIDTools::UUID.parse_raw( val) }
@queue = @env[ "newids.queue", :type => SBDB::Queue,
:flags => SBDB::CREATE | SBDB::AUTO_COMMIT, :re_len => 16]
@dbs, @counter = Cache.new, 0
@dbs, @counter = {}, 0
self.hash_func = lambda {|k|
n = k.timestamp.to_i
n -= n % 3600