Inspector added (loganinc --inspector)
This commit is contained in:
parent
b76953f57d
commit
76a05892db
2 changed files with 14 additions and 2 deletions
12
bin/loganinc
12
bin/loganinc
|
@ -4,6 +4,7 @@ require 'logan'
|
||||||
require 'logan/inc'
|
require 'logan/inc'
|
||||||
|
|
||||||
opts = {}
|
opts = {}
|
||||||
|
opts[:inspector] = ARGV[0] == '--inspector' ? ARGV.shift : false
|
||||||
opts[:server] = if ARGV[1]
|
opts[:server] = if ARGV[1]
|
||||||
ARGV
|
ARGV
|
||||||
elsif ARGV[0]
|
elsif ARGV[0]
|
||||||
|
@ -14,6 +15,17 @@ opts[:server][1] = opts[:server][1].to_i
|
||||||
|
|
||||||
logan = LogAn::Inc::Main.new opts
|
logan = LogAn::Inc::Main.new opts
|
||||||
begin
|
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
|
logan.main
|
||||||
rescue Object
|
rescue Object
|
||||||
logan.at_exit
|
logan.at_exit
|
||||||
|
|
|
@ -30,10 +30,10 @@ module LogAn
|
||||||
AutoKeyConvertHash.new(
|
AutoKeyConvertHash.new(
|
||||||
@env[ 'rotates.db', :type => SBDB::Btree, :flags => SBDB::CREATE | SBDB::AUTO_COMMIT],
|
@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 {|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,
|
@queue = @env[ "newids.queue", :type => SBDB::Queue,
|
||||||
:flags => SBDB::CREATE | SBDB::AUTO_COMMIT, :re_len => 16]
|
:flags => SBDB::CREATE | SBDB::AUTO_COMMIT, :re_len => 16]
|
||||||
@dbs, @counter = Cache.new, 0
|
@dbs, @counter = {}, 0
|
||||||
self.hash_func = lambda {|k|
|
self.hash_func = lambda {|k|
|
||||||
n = k.timestamp.to_i
|
n = k.timestamp.to_i
|
||||||
n -= n % 3600
|
n -= n % 3600
|
||||||
|
|
Loading…
Reference in a new issue