317: def initialize(host, port, num_processors=20, timeout=120)
318: @socket = TCPServer.new(host, port)
319:
320: @classifier = URIClassifier.new
321: @req_queue = Queue.new
322: @host = host
323: @port = port
324: @num_processors = num_processors
325: @timeout = timeout
326:
327: @num_processors.times {|i| Thread.new do
328: while client = @req_queue.deq
329: begin
330: Timeout.timeout(@timeout) do
331: process_client(client)
332: end
333: rescue Timeout::Error
334: STDERR.puts "WARNING: Request took longer than #@timeout second timeout"
335: end
336: end
337: end
338: }
339: end