7 $stderr.puts
"tracker: #{s}" if ENV && ENV["DEBUG_GATEWAY"]
13 def initialize(instances
, socket_path
)
14 @instances = instances
15 @socket = File
.expand_path(socket_path
)
19 @instances.times
{ @listeners << Mutex
.new
}
21 message
"using #{@listeners.length} listeners"
22 message
"opening socket at #{@socket}"
24 @service = DRb
.start_service("drbunix://#{@socket}", self)
28 message
"listener requested"
30 mutex
= has_lock
= index
= nil
32 @listeners.each_with_index
do |mutex
, index
|
33 has_lock
= mutex
.try_lock
41 message
"obtained listener #{index}"
46 message
"released listener #{index}"
49 message
"dropping request because no listeners are available!"
53 def background(check_interval
= nil)
57 message
"Idle for #{check_interval}, shutting down" unless @active
66 socket_path
= ARGV.shift
67 instances
= ARGV.shift
.to_i
68 t
= Tracker
.new(instances
, socket_path
)
69 t
.background(ARGV.first
? ARGV.shift
.to_i
: 90)