fluentd 0.10.35 → 0.10.36
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- data/.travis.yml +13 -0
- data/ChangeLog +9 -0
- data/fluentd.gemspec +1 -1
- data/lib/fluent/buffer.rb +210 -214
- data/lib/fluent/command/fluentd.rb +4 -0
- data/lib/fluent/config.rb +1 -0
- data/lib/fluent/engine.rb +10 -10
- data/lib/fluent/output.rb +404 -406
- data/lib/fluent/plugin/buf_file.rb +146 -151
- data/lib/fluent/plugin/buf_memory.rb +62 -67
- data/lib/fluent/plugin/in_debug_agent.rb +27 -31
- data/lib/fluent/plugin/in_exec.rb +86 -90
- data/lib/fluent/plugin/in_forward.rb +171 -171
- data/lib/fluent/plugin/in_gc_stat.rb +43 -47
- data/lib/fluent/plugin/in_http.rb +214 -216
- data/lib/fluent/plugin/in_monitor_agent.rb +212 -214
- data/lib/fluent/plugin/in_object_space.rb +75 -79
- data/lib/fluent/plugin/in_status.rb +44 -50
- data/lib/fluent/plugin/in_stream.rb +159 -160
- data/lib/fluent/plugin/in_syslog.rb +149 -153
- data/lib/fluent/plugin/in_tail.rb +382 -387
- data/lib/fluent/plugin/out_copy.rb +40 -45
- data/lib/fluent/plugin/out_exec.rb +52 -57
- data/lib/fluent/plugin/out_exec_filter.rb +327 -331
- data/lib/fluent/plugin/out_file.rb +78 -74
- data/lib/fluent/plugin/out_forward.rb +410 -414
- data/lib/fluent/plugin/out_null.rb +15 -19
- data/lib/fluent/plugin/out_roundrobin.rb +63 -68
- data/lib/fluent/plugin/out_stdout.rb +9 -14
- data/lib/fluent/plugin/out_stream.rb +83 -90
- data/lib/fluent/plugin/out_test.rb +42 -46
- data/lib/fluent/supervisor.rb +15 -0
- data/lib/fluent/version.rb +1 -1
- data/test/plugin/in_stream.rb +2 -0
- data/test/plugin/out_file.rb +19 -1
- metadata +6 -5
@@ -16,42 +16,38 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
module Fluent
|
19
|
+
class DebugAgentInput < Input
|
20
|
+
Plugin.register_input('debug_agent', self)
|
19
21
|
|
22
|
+
def initialize
|
23
|
+
require 'drb/drb'
|
24
|
+
super
|
25
|
+
end
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
config_param :bind, :string, :default => '0.0.0.0'
|
30
|
-
config_param :port, :integer, :default => 24230
|
31
|
-
config_param :unix_path, :integer, :default => nil
|
32
|
-
#config_param :unix_mode # TODO
|
33
|
-
config_param :object, :string, :default => 'Engine'
|
27
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
28
|
+
config_param :port, :integer, :default => 24230
|
29
|
+
config_param :unix_path, :integer, :default => nil
|
30
|
+
#config_param :unix_mode # TODO
|
31
|
+
config_param :object, :string, :default => 'Engine'
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
def configure(conf)
|
34
|
+
super
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
def start
|
38
|
+
if @unix_path
|
39
|
+
require 'drb/unix'
|
40
|
+
uri = "drbunix:#{@unix_path}"
|
41
|
+
else
|
42
|
+
uri = "druby://#{@bind}:#{@port}"
|
43
|
+
end
|
44
|
+
$log.info "listening dRuby", :uri => uri, :object => @object
|
45
|
+
obj = eval(@object)
|
46
|
+
@server = DRb::DRbServer.new(uri, obj)
|
45
47
|
end
|
46
|
-
$log.info "listening dRuby", :uri => uri, :object => @object
|
47
|
-
obj = eval(@object)
|
48
|
-
@server = DRb::DRbServer.new(uri, obj)
|
49
|
-
end
|
50
48
|
|
51
|
-
|
52
|
-
|
49
|
+
def shutdown
|
50
|
+
@server.stop_service if @server
|
51
|
+
end
|
53
52
|
end
|
54
53
|
end
|
55
|
-
|
56
|
-
|
57
|
-
end
|
@@ -16,117 +16,113 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
module Fluent
|
19
|
+
class ExecInput < Input
|
20
|
+
Plugin.register_input('exec', self)
|
19
21
|
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
config_param :command, :string
|
27
|
+
config_param :keys, :string
|
28
|
+
config_param :tag, :string, :default => nil
|
29
|
+
config_param :tag_key, :string, :default => nil
|
30
|
+
config_param :time_key, :string, :default => nil
|
31
|
+
config_param :time_format, :string, :default => nil
|
32
|
+
config_param :run_interval, :time, :default => nil
|
33
|
+
|
34
|
+
def configure(conf)
|
35
|
+
super
|
36
|
+
|
37
|
+
if localtime = conf['localtime']
|
38
|
+
@localtime = true
|
39
|
+
elsif utc = conf['utc']
|
40
|
+
@localtime = false
|
41
|
+
end
|
27
42
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
config_param :tag_key, :string, :default => nil
|
32
|
-
config_param :time_key, :string, :default => nil
|
33
|
-
config_param :time_format, :string, :default => nil
|
34
|
-
config_param :run_interval, :time, :default => nil
|
43
|
+
if !@tag && !@tag_key
|
44
|
+
raise ConfigError, "'tag' or 'tag_key' option is required on exec input"
|
45
|
+
end
|
35
46
|
|
36
|
-
|
37
|
-
super
|
47
|
+
@keys = @keys.split(',')
|
38
48
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
49
|
+
if @time_key
|
50
|
+
if @time_format
|
51
|
+
f = @time_format
|
52
|
+
@time_parse_proc = Proc.new {|str| Time.strptime(str, f).to_i }
|
53
|
+
else
|
54
|
+
@time_parse_proc = Proc.new {|str| str.to_i }
|
55
|
+
end
|
56
|
+
end
|
43
57
|
end
|
44
58
|
|
45
|
-
|
46
|
-
|
59
|
+
def start
|
60
|
+
if @run_interval
|
61
|
+
@finished = false
|
62
|
+
@thread = Thread.new(&method(:run_periodic))
|
63
|
+
else
|
64
|
+
@io = IO.popen(@command, "r")
|
65
|
+
@pid = @io.pid
|
66
|
+
@thread = Thread.new(&method(:run))
|
67
|
+
end
|
47
68
|
end
|
48
69
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
f = @time_format
|
54
|
-
@time_parse_proc = Proc.new {|str| Time.strptime(str, f).to_i }
|
70
|
+
def shutdown
|
71
|
+
if @run_interval
|
72
|
+
@finished = true
|
73
|
+
@thread.join
|
55
74
|
else
|
56
|
-
|
75
|
+
Process.kill(:TERM, @pid)
|
76
|
+
if @thread.join(60) # TODO wait time
|
77
|
+
return
|
78
|
+
end
|
79
|
+
Process.kill(:KILL, @pid)
|
80
|
+
@thread.join
|
57
81
|
end
|
58
82
|
end
|
59
|
-
end
|
60
83
|
|
61
|
-
|
62
|
-
|
63
|
-
@finished = false
|
64
|
-
@thread = Thread.new(&method(:run_periodic))
|
65
|
-
else
|
66
|
-
@io = IO.popen(@command, "r")
|
67
|
-
@pid = @io.pid
|
68
|
-
@thread = Thread.new(&method(:run))
|
84
|
+
def run
|
85
|
+
@io.each_line(&method(:each_line))
|
69
86
|
end
|
70
|
-
end
|
71
87
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if @thread.join(60) # TODO wait time
|
79
|
-
return
|
88
|
+
def run_periodic
|
89
|
+
until @finished
|
90
|
+
sleep @run_interval
|
91
|
+
io = IO.popen(@command, "r")
|
92
|
+
io.each_line(&method(:each_line))
|
93
|
+
Process.waitpid(io.pid)
|
80
94
|
end
|
81
|
-
Process.kill(:KILL, @pid)
|
82
|
-
@thread.join
|
83
95
|
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def run
|
87
|
-
@io.each_line(&method(:each_line))
|
88
|
-
end
|
89
|
-
|
90
|
-
def run_periodic
|
91
|
-
until @finished
|
92
|
-
sleep @run_interval
|
93
|
-
io = IO.popen(@command, "r")
|
94
|
-
io.each_line(&method(:each_line))
|
95
|
-
Process.waitpid(io.pid)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
private
|
100
|
-
def each_line(line)
|
101
|
-
begin
|
102
|
-
line.chomp!
|
103
|
-
vals = line.split("\t")
|
104
96
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
97
|
+
private
|
98
|
+
def each_line(line)
|
99
|
+
begin
|
100
|
+
line.chomp!
|
101
|
+
vals = line.split("\t")
|
102
|
+
|
103
|
+
tag = @tag
|
104
|
+
time = nil
|
105
|
+
record = {}
|
106
|
+
for i in 0..@keys.length-1
|
107
|
+
key = @keys[i]
|
108
|
+
val = vals[i]
|
109
|
+
if key == @time_key
|
110
|
+
time = @time_parse_proc.call(val)
|
111
|
+
elsif key == @tag_key
|
112
|
+
tag = val
|
113
|
+
else
|
114
|
+
record[key] = val
|
115
|
+
end
|
117
116
|
end
|
118
|
-
end
|
119
117
|
|
120
|
-
|
121
|
-
|
122
|
-
|
118
|
+
if tag
|
119
|
+
time ||= Engine.now
|
120
|
+
Engine.emit(tag, time, record)
|
121
|
+
end
|
122
|
+
rescue
|
123
|
+
$log.error "exec failed to emit", :error=>$!.to_s, :line=>line
|
124
|
+
$log.warn_backtrace $!.backtrace
|
123
125
|
end
|
124
|
-
rescue
|
125
|
-
$log.error "exec failed to emit", :error=>$!.to_s, :line=>line
|
126
|
-
$log.warn_backtrace $!.backtrace
|
127
126
|
end
|
128
127
|
end
|
129
128
|
end
|
130
|
-
|
131
|
-
|
132
|
-
end
|
@@ -18,207 +18,207 @@
|
|
18
18
|
module Fluent
|
19
19
|
|
20
20
|
|
21
|
-
class ForwardInput < Input
|
22
|
-
|
21
|
+
class ForwardInput < Input
|
22
|
+
Plugin.register_input('forward', self)
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
config_param :port, :integer, :default => DEFAULT_LISTEN_PORT
|
30
|
-
config_param :bind, :string, :default => '0.0.0.0'
|
31
|
-
|
32
|
-
def configure(conf)
|
33
|
-
super
|
34
|
-
end
|
24
|
+
def initialize
|
25
|
+
super
|
26
|
+
require 'fluent/plugin/socket_util'
|
27
|
+
end
|
35
28
|
|
36
|
-
|
37
|
-
|
29
|
+
config_param :port, :integer, :default => DEFAULT_LISTEN_PORT
|
30
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
31
|
+
config_param :backlog, :integer, :default => nil
|
38
32
|
|
39
|
-
|
40
|
-
|
33
|
+
def configure(conf)
|
34
|
+
super
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
@usock.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)
|
45
|
-
@hbr = HeartbeatRequestHandler.new(@usock, method(:on_heartbeat_request))
|
46
|
-
@loop.attach(@hbr)
|
37
|
+
def start
|
38
|
+
@loop = Coolio::Loop.new
|
47
39
|
|
48
|
-
|
49
|
-
|
50
|
-
end
|
40
|
+
@lsock = listen
|
41
|
+
@loop.attach(@lsock)
|
51
42
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
TCPSocket.open(listen_address, @port) {|sock| } # FIXME @thread.join blocks without this line
|
58
|
-
@thread.join
|
59
|
-
@lsock.close
|
60
|
-
end
|
43
|
+
@usock = SocketUtil.create_udp_socket(@bind)
|
44
|
+
@usock.bind(@bind, @port)
|
45
|
+
@usock.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)
|
46
|
+
@hbr = HeartbeatRequestHandler.new(@usock, method(:on_heartbeat_request))
|
47
|
+
@loop.attach(@hbr)
|
61
48
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
49
|
+
@thread = Thread.new(&method(:run))
|
50
|
+
@cached_unpacker = $use_msgpack_5 ? nil : MessagePack::Unpacker.new
|
51
|
+
end
|
66
52
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
#
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
def run
|
78
|
-
@loop.run
|
79
|
-
rescue
|
80
|
-
$log.error "unexpected error", :error=>$!.to_s
|
81
|
-
$log.error_backtrace
|
82
|
-
end
|
53
|
+
def shutdown
|
54
|
+
@loop.watchers.each {|w| w.detach }
|
55
|
+
@loop.stop
|
56
|
+
@usock.close
|
57
|
+
listen_address = (@bind == '0.0.0.0' ? '127.0.0.1' : @bind)
|
58
|
+
TCPSocket.open(listen_address, @port) {|sock| } # FIXME @thread.join blocks without this line
|
59
|
+
@thread.join
|
60
|
+
@lsock.close
|
61
|
+
end
|
83
62
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
# message Forward {
|
91
|
-
# 1: string tag
|
92
|
-
# 2: list<Entry> entries
|
93
|
-
# }
|
94
|
-
#
|
95
|
-
# message PackedForward {
|
96
|
-
# 1: string tag
|
97
|
-
# 2: raw entries # msgpack stream of Entry
|
98
|
-
# }
|
99
|
-
#
|
100
|
-
# message Message {
|
101
|
-
# 1: string tag
|
102
|
-
# 2: long? time
|
103
|
-
# 3: object record
|
104
|
-
# }
|
105
|
-
def on_message(msg)
|
106
|
-
if msg.nil?
|
107
|
-
# for future TCP heartbeat_request
|
108
|
-
return
|
63
|
+
def listen
|
64
|
+
$log.info "listening fluent socket on #{@bind}:#{@port}"
|
65
|
+
s = Coolio::TCPServer.new(@bind, @port, Handler, method(:on_message))
|
66
|
+
s.listen(@backlog) unless @backlog.nil?
|
67
|
+
s
|
109
68
|
end
|
110
69
|
|
111
|
-
#
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
record = e[1]
|
127
|
-
es.add(time, record)
|
128
|
-
}
|
129
|
-
Engine.emit_stream(tag, es)
|
130
|
-
|
131
|
-
else
|
132
|
-
# Message
|
133
|
-
time = msg[1]
|
134
|
-
time = Engine.now if time == 0
|
135
|
-
record = msg[2]
|
136
|
-
Engine.emit(tag, time, record)
|
70
|
+
#config_param :path, :string, :default => DEFAULT_SOCKET_PATH
|
71
|
+
#def listen
|
72
|
+
# if File.exist?(@path)
|
73
|
+
# File.unlink(@path)
|
74
|
+
# end
|
75
|
+
# FileUtils.mkdir_p File.dirname(@path)
|
76
|
+
# $log.debug "listening fluent socket on #{@path}"
|
77
|
+
# Coolio::UNIXServer.new(@path, Handler, method(:on_message))
|
78
|
+
#end
|
79
|
+
|
80
|
+
def run
|
81
|
+
@loop.run
|
82
|
+
rescue
|
83
|
+
$log.error "unexpected error", :error=>$!.to_s
|
84
|
+
$log.error_backtrace
|
137
85
|
end
|
138
|
-
end
|
139
86
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
87
|
+
protected
|
88
|
+
# message Entry {
|
89
|
+
# 1: long time
|
90
|
+
# 2: object record
|
91
|
+
# }
|
92
|
+
#
|
93
|
+
# message Forward {
|
94
|
+
# 1: string tag
|
95
|
+
# 2: list<Entry> entries
|
96
|
+
# }
|
97
|
+
#
|
98
|
+
# message PackedForward {
|
99
|
+
# 1: string tag
|
100
|
+
# 2: raw entries # msgpack stream of Entry
|
101
|
+
# }
|
102
|
+
#
|
103
|
+
# message Message {
|
104
|
+
# 1: string tag
|
105
|
+
# 2: long? time
|
106
|
+
# 3: object record
|
107
|
+
# }
|
108
|
+
def on_message(msg)
|
109
|
+
if msg.nil?
|
110
|
+
# for future TCP heartbeat_request
|
111
|
+
return
|
146
112
|
end
|
147
|
-
$log.trace { "accepted fluent socket object_id=#{self.object_id}" }
|
148
|
-
@on_message = on_message
|
149
|
-
end
|
150
113
|
|
151
|
-
|
152
|
-
|
114
|
+
# TODO format error
|
115
|
+
tag = msg[0].to_s
|
116
|
+
entries = msg[1]
|
117
|
+
|
118
|
+
if entries.class == String
|
119
|
+
# PackedForward
|
120
|
+
es = MessagePackEventStream.new(entries, @cached_unpacker)
|
121
|
+
Engine.emit_stream(tag, es)
|
122
|
+
|
123
|
+
elsif entries.class == Array
|
124
|
+
# Forward
|
125
|
+
es = MultiEventStream.new
|
126
|
+
entries.each {|e|
|
127
|
+
time = e[0].to_i
|
128
|
+
time = (now ||= Engine.now) if time == 0
|
129
|
+
record = e[1]
|
130
|
+
es.add(time, record)
|
131
|
+
}
|
132
|
+
Engine.emit_stream(tag, es)
|
153
133
|
|
154
|
-
def on_read(data)
|
155
|
-
first = data[0]
|
156
|
-
if first == '{' || first == '['
|
157
|
-
m = method(:on_read_json)
|
158
|
-
@y = Yajl::Parser.new
|
159
|
-
@y.on_parse_complete = @on_message
|
160
134
|
else
|
161
|
-
|
162
|
-
|
135
|
+
# Message
|
136
|
+
time = msg[1]
|
137
|
+
time = Engine.now if time == 0
|
138
|
+
record = msg[2]
|
139
|
+
Engine.emit(tag, time, record)
|
163
140
|
end
|
141
|
+
end
|
164
142
|
|
165
|
-
|
166
|
-
|
143
|
+
class Handler < Coolio::Socket
|
144
|
+
def initialize(io, on_message)
|
145
|
+
super(io)
|
146
|
+
if io.is_a?(TCPSocket)
|
147
|
+
opt = [1, @timeout.to_i].pack('I!I!') # { int l_onoff; int l_linger; }
|
148
|
+
io.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, opt)
|
149
|
+
end
|
150
|
+
$log.trace { "accepted fluent socket object_id=#{self.object_id}" }
|
151
|
+
@on_message = on_message
|
167
152
|
end
|
168
|
-
m.call(data)
|
169
|
-
end
|
170
153
|
|
171
|
-
|
172
|
-
|
173
|
-
rescue
|
174
|
-
$log.error "forward error: #{$!.to_s}"
|
175
|
-
$log.error_backtrace
|
176
|
-
close
|
177
|
-
end
|
154
|
+
def on_connect
|
155
|
+
end
|
178
156
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
157
|
+
def on_read(data)
|
158
|
+
first = data[0]
|
159
|
+
if first == '{' || first == '['
|
160
|
+
m = method(:on_read_json)
|
161
|
+
@y = Yajl::Parser.new
|
162
|
+
@y.on_parse_complete = @on_message
|
163
|
+
else
|
164
|
+
m = method(:on_read_msgpack)
|
165
|
+
@u = MessagePack::Unpacker.new
|
166
|
+
end
|
167
|
+
|
168
|
+
(class << self; self; end).module_eval do
|
169
|
+
define_method(:on_read, m)
|
170
|
+
end
|
171
|
+
m.call(data)
|
172
|
+
end
|
173
|
+
|
174
|
+
def on_read_json(data)
|
175
|
+
@y << data
|
176
|
+
rescue
|
177
|
+
$log.error "forward error: #{$!.to_s}"
|
178
|
+
$log.error_backtrace
|
179
|
+
close
|
180
|
+
end
|
181
|
+
|
182
|
+
def on_read_msgpack(data)
|
183
|
+
@u.feed_each(data, &@on_message)
|
184
|
+
rescue
|
185
|
+
$log.error "forward error: #{$!.to_s}"
|
186
|
+
$log.error_backtrace
|
187
|
+
close
|
188
|
+
end
|
186
189
|
|
187
|
-
|
188
|
-
|
190
|
+
def on_close
|
191
|
+
$log.trace { "closed fluent socket object_id=#{self.object_id}" }
|
192
|
+
end
|
189
193
|
end
|
190
|
-
end
|
191
194
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
195
|
+
class HeartbeatRequestHandler < Coolio::IO
|
196
|
+
def initialize(io, callback)
|
197
|
+
super(io)
|
198
|
+
@io = io
|
199
|
+
@callback = callback
|
200
|
+
end
|
201
|
+
|
202
|
+
def on_readable
|
203
|
+
begin
|
204
|
+
msg, addr = @io.recvfrom(1024)
|
205
|
+
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR
|
206
|
+
return
|
207
|
+
end
|
208
|
+
host = addr[3]
|
209
|
+
port = addr[1]
|
210
|
+
@callback.call(host, port, msg)
|
211
|
+
rescue
|
212
|
+
# TODO log?
|
213
|
+
end
|
197
214
|
end
|
198
215
|
|
199
|
-
def
|
216
|
+
def on_heartbeat_request(host, port, msg)
|
217
|
+
#$log.trace "heartbeat request from #{host}:#{port}"
|
200
218
|
begin
|
201
|
-
|
219
|
+
@usock.send "\0", 0, host, port
|
202
220
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR
|
203
|
-
return
|
204
221
|
end
|
205
|
-
host = addr[3]
|
206
|
-
port = addr[1]
|
207
|
-
@callback.call(host, port, msg)
|
208
|
-
rescue
|
209
|
-
# TODO log?
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def on_heartbeat_request(host, port, msg)
|
214
|
-
#$log.trace "heartbeat request from #{host}:#{port}"
|
215
|
-
begin
|
216
|
-
@usock.send "\0", 0, host, port
|
217
|
-
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINTR
|
218
222
|
end
|
219
223
|
end
|
220
224
|
end
|
221
|
-
|
222
|
-
|
223
|
-
end
|
224
|
-
|