7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/horobi/sub.rb', line 7
def self.init
options = {
"logfile" => STDERR,
"inputs" => [],
}
OptionParser.new do |op|
op.on('-p VAL','--pidfile=VAL','pidfile path'){|v| options["pidfile"] = v}
op.on('-l VAL','--logfile=VAL','logfile path'){|v| options["logfile"] = (v == "-" ? STDOUT : v)}
op.on('-i VAL','--input-points=VAL',
"input(hub's output) point(s) such as 'tcp://127.0.0.1:5551,tcp://127.0.11.1:5551'"){|v| options["inputs"] = v.split(",")}
op.parse!(ARGV)
end
@options = options
if @options["inputs"].compact.length < 1
raise "subscribe input points are undefined"
end
@logger = Logger.new(options["logfile"])
@sock ||= begin
sock = @context.socket(ZMQ::SUB)
@options["inputs"].each do |point|
@logger.info("connecting to #{point}")
sock.connect(point)
end
sock.setsockopt(ZMQ::LINGER, 100)
sock
end
end
|