45: def start(config,protocol = AnaloggerProtocol)
46: @config = config
47: daemonize if @config[Cdaemonize]
48: File.open(@config[Cpidfile],'w+') {|fh| fh.puts $$} if @config[Cpidfile]
49: @logs = Hash.new {|h,k| h[k] = new_log(k)}
50: @queue = Hash.new {|h,k| h[k] = []}
51: postprocess_config_load
52: check_config_settings
53: populate_logs
54: set_config_defaults
55: @rcount = 0
56: @wcount = 0
57: trap("INT") {cleanup;exit}
58: trap("TERM") {cleanup;exit}
59: trap("HUP") {cleanup;throw :hup}
60: EventMachine.run {
61: EventMachine.start_server @config[Chost], @config[Cport], protocol
62: EventMachine.add_periodic_timer(1) {Analogger.update_now}
63: EventMachine.add_periodic_timer(@config[Cinterval]) {write_queue}
64: EventMachine.add_periodic_timer(@config[Csyncinterval]) {flush_queue}
65: }
66: end