fluentd 1.11.2-x64-mingw32 → 1.12.1-x64-mingw32
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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/workflows/build.yaml +29 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.travis.yml +22 -2
- data/CHANGELOG.md +114 -0
- data/README.md +2 -2
- data/appveyor.yml +3 -0
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-ctl +7 -0
- data/fluentd.gemspec +8 -8
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/command/ca_generate.rb +6 -3
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/ctl.rb +177 -0
- data/lib/fluent/command/fluentd.rb +4 -0
- data/lib/fluent/command/plugin_config_formatter.rb +17 -2
- data/lib/fluent/config/section.rb +1 -1
- data/lib/fluent/env.rb +4 -0
- data/lib/fluent/log.rb +33 -3
- data/lib/fluent/plugin.rb +5 -0
- data/lib/fluent/plugin/buffer.rb +27 -57
- data/lib/fluent/plugin/buffer/chunk.rb +2 -1
- data/lib/fluent/plugin/formatter.rb +24 -0
- data/lib/fluent/plugin/formatter_csv.rb +1 -1
- data/lib/fluent/plugin/formatter_hash.rb +3 -1
- data/lib/fluent/plugin/formatter_json.rb +3 -1
- data/lib/fluent/plugin/formatter_ltsv.rb +5 -3
- data/lib/fluent/plugin/formatter_out_file.rb +6 -4
- data/lib/fluent/plugin/formatter_single_value.rb +4 -2
- data/lib/fluent/plugin/formatter_tsv.rb +4 -2
- data/lib/fluent/plugin/in_exec.rb +4 -2
- data/lib/fluent/plugin/in_http.rb +23 -2
- data/lib/fluent/plugin/in_tail.rb +109 -41
- data/lib/fluent/plugin/in_tail/position_file.rb +39 -14
- data/lib/fluent/plugin/in_tcp.rb +1 -0
- data/lib/fluent/plugin/out_http.rb +29 -4
- data/lib/fluent/plugin/output.rb +15 -6
- data/lib/fluent/plugin/parser_json.rb +5 -2
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +1 -1
- data/lib/fluent/plugin_helper/inject.rb +4 -1
- data/lib/fluent/plugin_helper/retry_state.rb +4 -0
- data/lib/fluent/supervisor.rb +162 -51
- data/lib/fluent/system_config.rb +4 -2
- data/lib/fluent/time.rb +1 -0
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +22 -4
- data/templates/plugin_config_formatter/param.md-table.erb +10 -0
- data/test/command/test_binlog_reader.rb +22 -6
- data/test/command/test_cap_ctl.rb +100 -0
- data/test/command/test_ctl.rb +57 -0
- data/test/command/test_fluentd.rb +30 -0
- data/test/command/test_plugin_config_formatter.rb +124 -2
- data/test/plugin/in_tail/test_position_file.rb +46 -26
- data/test/plugin/test_buffer.rb +4 -0
- data/test/plugin/test_filter_stdout.rb +6 -1
- data/test/plugin/test_formatter_hash.rb +6 -3
- data/test/plugin/test_formatter_json.rb +14 -4
- data/test/plugin/test_formatter_ltsv.rb +13 -5
- data/test/plugin/test_formatter_out_file.rb +35 -14
- data/test/plugin/test_formatter_single_value.rb +12 -6
- data/test/plugin/test_formatter_tsv.rb +12 -4
- data/test/plugin/test_in_exec.rb +18 -0
- data/test/plugin/test_in_http.rb +25 -0
- data/test/plugin/test_in_tail.rb +433 -30
- data/test/plugin/test_out_file.rb +23 -18
- data/test/plugin/test_out_http.rb +19 -0
- data/test/plugin/test_output.rb +12 -0
- data/test/plugin/test_parser_syslog.rb +2 -2
- data/test/plugin/test_sd_file.rb +1 -1
- data/test/plugin_helper/test_compat_parameters.rb +7 -2
- data/test/plugin_helper/test_http_server_helper.rb +8 -1
- data/test/plugin_helper/test_inject.rb +42 -0
- data/test/plugin_helper/test_server.rb +18 -5
- data/test/test_capability.rb +74 -0
- data/test/test_formatter.rb +34 -10
- data/test/test_log.rb +44 -0
- data/test/test_output.rb +6 -1
- data/test/test_supervisor.rb +150 -1
- metadata +49 -37
data/lib/fluent/plugin/in_tcp.rb
CHANGED
@@ -98,6 +98,7 @@ module Fluent::Plugin
|
|
98
98
|
def start
|
99
99
|
super
|
100
100
|
|
101
|
+
log.info "listening tcp socket", bind: @bind, port: @port
|
101
102
|
del_size = @delimiter.length
|
102
103
|
if @_extract_enabled && @_extract_tag_key
|
103
104
|
server_create(:in_tcp_server_single_emit, @port, bind: @bind, resolve_name: !!@source_hostname_key) do |data, conn|
|
@@ -21,6 +21,16 @@ require 'fluent/tls'
|
|
21
21
|
require 'fluent/plugin/output'
|
22
22
|
require 'fluent/plugin_helper/socket'
|
23
23
|
|
24
|
+
# patch Net::HTTP to support extra_chain_cert which was added in Ruby feature #9758.
|
25
|
+
# see: https://github.com/ruby/ruby/commit/31af0dafba6d3769d2a39617c0dddedb97883712
|
26
|
+
unless Net::HTTP::SSL_IVNAMES.include?(:@extra_chain_cert)
|
27
|
+
class Net::HTTP
|
28
|
+
SSL_IVNAMES << :@extra_chain_cert
|
29
|
+
SSL_ATTRIBUTES << :extra_chain_cert
|
30
|
+
attr_accessor :extra_chain_cert
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
module Fluent::Plugin
|
25
35
|
class HTTPOutput < Output
|
26
36
|
Fluent::Plugin.register_output('http', self)
|
@@ -41,6 +51,8 @@ module Fluent::Plugin
|
|
41
51
|
config_param :json_array, :bool, default: false
|
42
52
|
desc 'Additional headers for HTTP request'
|
43
53
|
config_param :headers, :hash, default: nil
|
54
|
+
desc 'Additional placeholder based headers for HTTP request'
|
55
|
+
config_param :headers_from_placeholders, :hash, default: nil
|
44
56
|
|
45
57
|
desc 'The connection open timeout in seconds'
|
46
58
|
config_param :open_timeout, :integer, default: nil
|
@@ -171,7 +183,15 @@ module Fluent::Plugin
|
|
171
183
|
end
|
172
184
|
if @tls_client_cert_path
|
173
185
|
raise Fluent::ConfigError, "tls_client_cert_path is wrong: #{@tls_client_cert_path}" unless File.file?(@tls_client_cert_path)
|
174
|
-
|
186
|
+
|
187
|
+
bundle = File.read(@tls_client_cert_path)
|
188
|
+
bundle_certs = bundle.scan(/-----BEGIN CERTIFICATE-----(?:.|\n)+?-----END CERTIFICATE-----/)
|
189
|
+
opt[:cert] = OpenSSL::X509::Certificate.new(bundle_certs[0])
|
190
|
+
|
191
|
+
intermediate_certs = bundle_certs[1..-1]
|
192
|
+
if intermediate_certs
|
193
|
+
opt[:extra_chain_cert] = intermediate_certs.map { |cert| OpenSSL::X509::Certificate.new(cert) }
|
194
|
+
end
|
175
195
|
end
|
176
196
|
if @tls_private_key_path
|
177
197
|
raise Fluent::ConfigError, "tls_private_key_path is wrong: #{@tls_private_key_path}" unless File.file?(@tls_private_key_path)
|
@@ -195,12 +215,17 @@ module Fluent::Plugin
|
|
195
215
|
URI.parse(endpoint)
|
196
216
|
end
|
197
217
|
|
198
|
-
def set_headers(req)
|
218
|
+
def set_headers(req, chunk)
|
199
219
|
if @headers
|
200
220
|
@headers.each do |k, v|
|
201
221
|
req[k] = v
|
202
222
|
end
|
203
223
|
end
|
224
|
+
if @headers_from_placeholders
|
225
|
+
@headers_from_placeholders.each do |k, v|
|
226
|
+
req[k] = extract_placeholders(v, chunk)
|
227
|
+
end
|
228
|
+
end
|
204
229
|
req['Content-Type'] = @content_type
|
205
230
|
end
|
206
231
|
|
@@ -214,8 +239,8 @@ module Fluent::Plugin
|
|
214
239
|
if @auth
|
215
240
|
req.basic_auth(@auth.username, @auth.password)
|
216
241
|
end
|
217
|
-
set_headers(req)
|
218
|
-
req.body = @json_array ? "[#{chunk.read.chop
|
242
|
+
set_headers(req, chunk)
|
243
|
+
req.body = @json_array ? "[#{chunk.read.chop}]" : chunk.read
|
219
244
|
req
|
220
245
|
end
|
221
246
|
|
data/lib/fluent/plugin/output.rb
CHANGED
@@ -340,6 +340,7 @@ module Fluent
|
|
340
340
|
buffer_conf = conf.elements(name: 'buffer').first || Fluent::Config::Element.new('buffer', '', {}, [])
|
341
341
|
@buffer = Plugin.new_buffer(buffer_type, parent: self)
|
342
342
|
@buffer.configure(buffer_conf)
|
343
|
+
@buffer.enable_update_timekeys if @chunk_key_time
|
343
344
|
|
344
345
|
@flush_at_shutdown = @buffer_config.flush_at_shutdown
|
345
346
|
if @flush_at_shutdown.nil?
|
@@ -768,17 +769,19 @@ module Fluent
|
|
768
769
|
end
|
769
770
|
end
|
770
771
|
|
771
|
-
|
772
|
-
log.warn "chunk key placeholder '#{$1}' not replaced. template:#{str}"
|
773
|
-
end
|
774
|
-
|
775
|
-
rvalue.sub(CHUNK_ID_PLACEHOLDER_PATTERN) {
|
772
|
+
rvalue = rvalue.sub(CHUNK_ID_PLACEHOLDER_PATTERN) {
|
776
773
|
if chunk_passed
|
777
774
|
dump_unique_id_hex(chunk.unique_id)
|
778
775
|
else
|
779
776
|
log.warn "${chunk_id} is not allowed in this plugin. Pass Chunk instead of metadata in extract_placeholders's 2nd argument"
|
780
777
|
end
|
781
778
|
}
|
779
|
+
|
780
|
+
if rvalue =~ CHUNK_KEY_PLACEHOLDER_PATTERN
|
781
|
+
log.warn "chunk key placeholder '#{$1}' not replaced. template:#{str}"
|
782
|
+
end
|
783
|
+
|
784
|
+
rvalue
|
782
785
|
end
|
783
786
|
end
|
784
787
|
|
@@ -1249,7 +1252,13 @@ module Fluent
|
|
1249
1252
|
log.debug "buffer queue cleared"
|
1250
1253
|
@retry = nil
|
1251
1254
|
else
|
1252
|
-
@retry.
|
1255
|
+
# Ensure that the current time is greater than or equal to @retry.next_time to avoid the situation when
|
1256
|
+
# @retry.step is called almost as many times as the number of flush threads in a short time.
|
1257
|
+
if Time.now >= @retry.next_time
|
1258
|
+
@retry.step
|
1259
|
+
else
|
1260
|
+
@retry.recalc_next_time # to prevent all flush threads from retrying at the same time
|
1261
|
+
end
|
1253
1262
|
if error
|
1254
1263
|
if using_secondary
|
1255
1264
|
msg = "failed to flush the buffer with secondary output."
|
@@ -71,8 +71,11 @@ module Fluent
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def parse(text)
|
74
|
-
|
75
|
-
time
|
74
|
+
record = @load_proc.call(text)
|
75
|
+
time = parse_time(record)
|
76
|
+
if @execute_convert_values
|
77
|
+
time, record = convert_values(time, record)
|
78
|
+
end
|
76
79
|
yield time, record
|
77
80
|
rescue @error_class, EncodingError # EncodingError is for oj 3.x or later
|
78
81
|
yield nil, nil
|
@@ -81,7 +81,7 @@ module Fluent
|
|
81
81
|
|
82
82
|
def build_handler
|
83
83
|
@methods.group_by(&:first).each do |(path, rest)|
|
84
|
-
klass = Fluent::PluginHelper::HttpServer::Compat::WebrickHandler.build(Hash[rest.map { |e| [e[1], e[2]] }])
|
84
|
+
klass = Fluent::PluginHelper::HttpServer::Compat::WebrickHandler.build(**Hash[rest.map { |e| [e[1], e[2]] }])
|
85
85
|
@server.mount(path, klass)
|
86
86
|
end
|
87
87
|
end
|
@@ -76,7 +76,7 @@ module Fluent
|
|
76
76
|
config_param :time_key, :string, default: nil
|
77
77
|
|
78
78
|
# To avoid defining :time_type twice
|
79
|
-
config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float
|
79
|
+
config_param :time_type, :enum, list: [:float, :unixtime, :unixtime_millis, :unixtime_micros, :unixtime_nanos, :string], default: :float
|
80
80
|
|
81
81
|
Fluent::TimeMixin::TIME_PARAMETERS.each do |name, type, opts|
|
82
82
|
config_param(name, type, **opts)
|
@@ -132,6 +132,9 @@ module Fluent
|
|
132
132
|
if @_inject_time_key
|
133
133
|
@_inject_time_formatter = case @inject_config.time_type
|
134
134
|
when :float then ->(time){ time.to_r.truncate(+6).to_f } # microsecond floating point value
|
135
|
+
when :unixtime_millis then ->(time) { time.respond_to?(:nsec) ? time.to_i * 1_000 + time.nsec / 1_000_000 : (time * 1_000).floor }
|
136
|
+
when :unixtime_micros then ->(time) { time.respond_to?(:nsec) ? time.to_i * 1_000_000 + time.nsec / 1_000 : (time * 1_000_000).floor }
|
137
|
+
when :unixtime_nanos then ->(time) { time.respond_to?(:nsec) ? time.to_i * 1_000_000_000 + time.nsec : (time * 1_000_000_000).floor }
|
135
138
|
when :unixtime then ->(time){ time.to_i }
|
136
139
|
else
|
137
140
|
localtime = @inject_config.localtime && !@inject_config.utc
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -45,6 +45,7 @@ module Fluent
|
|
45
45
|
module ServerModule
|
46
46
|
def before_run
|
47
47
|
@fluentd_conf = config[:fluentd_conf]
|
48
|
+
@rpc_endpoint = nil
|
48
49
|
@rpc_server = nil
|
49
50
|
@counter = nil
|
50
51
|
|
@@ -53,23 +54,28 @@ module Fluent
|
|
53
54
|
@enable_get_dump = config[:enable_get_dump]
|
54
55
|
run_rpc_server
|
55
56
|
end
|
56
|
-
install_supervisor_signal_handlers
|
57
57
|
|
58
|
-
if
|
59
|
-
@signame = config[:signame]
|
58
|
+
if Fluent.windows?
|
60
59
|
install_windows_event_handler
|
60
|
+
else
|
61
|
+
install_supervisor_signal_handlers
|
61
62
|
end
|
62
63
|
|
63
64
|
if counter = config[:counter_server]
|
64
65
|
run_counter_server(counter)
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
if config[:disable_shared_socket]
|
69
|
+
$log.info "shared socket for multiple workers is disabled"
|
70
|
+
else
|
71
|
+
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
|
72
|
+
ServerEngine::SocketManager::Server.open(socket_manager_path)
|
73
|
+
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
|
74
|
+
end
|
70
75
|
end
|
71
76
|
|
72
77
|
def after_run
|
78
|
+
stop_windows_event_thread if Fluent.windows?
|
73
79
|
stop_rpc_server if @rpc_endpoint
|
74
80
|
stop_counter_server if @counter
|
75
81
|
Fluent::Supervisor.cleanup_resources
|
@@ -92,7 +98,8 @@ module Fluent
|
|
92
98
|
@rpc_server.mount_proc('/api/processes.flushBuffersAndKillWorkers') { |req, res|
|
93
99
|
$log.debug "fluentd RPC got /api/processes.flushBuffersAndKillWorkers request"
|
94
100
|
if Fluent.windows?
|
95
|
-
|
101
|
+
supervisor_sigusr1_handler
|
102
|
+
stop(true)
|
96
103
|
else
|
97
104
|
Process.kill :USR1, $$
|
98
105
|
Process.kill :TERM, $$
|
@@ -101,7 +108,9 @@ module Fluent
|
|
101
108
|
}
|
102
109
|
@rpc_server.mount_proc('/api/plugins.flushBuffers') { |req, res|
|
103
110
|
$log.debug "fluentd RPC got /api/plugins.flushBuffers request"
|
104
|
-
|
111
|
+
if Fluent.windows?
|
112
|
+
supervisor_sigusr1_handler
|
113
|
+
else
|
105
114
|
Process.kill :USR1, $$
|
106
115
|
end
|
107
116
|
nil
|
@@ -125,7 +134,9 @@ module Fluent
|
|
125
134
|
|
126
135
|
@rpc_server.mount_proc('/api/config.gracefulReload') { |req, res|
|
127
136
|
$log.debug "fluentd RPC got /api/config.gracefulReload request"
|
128
|
-
|
137
|
+
if Fluent.windows?
|
138
|
+
supervisor_sigusr2_handler
|
139
|
+
else
|
129
140
|
Process.kill :USR2, $$
|
130
141
|
end
|
131
142
|
|
@@ -159,38 +170,101 @@ module Fluent
|
|
159
170
|
end
|
160
171
|
|
161
172
|
def install_supervisor_signal_handlers
|
173
|
+
return if Fluent.windows?
|
174
|
+
|
162
175
|
trap :HUP do
|
163
176
|
$log.debug "fluentd supervisor process get SIGHUP"
|
164
177
|
supervisor_sighup_handler
|
165
|
-
end
|
178
|
+
end
|
166
179
|
|
167
180
|
trap :USR1 do
|
168
181
|
$log.debug "fluentd supervisor process get SIGUSR1"
|
169
182
|
supervisor_sigusr1_handler
|
170
|
-
end
|
183
|
+
end
|
171
184
|
|
172
185
|
trap :USR2 do
|
173
186
|
$log.debug 'fluentd supervisor process got SIGUSR2'
|
174
187
|
supervisor_sigusr2_handler
|
175
|
-
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
if Fluent.windows?
|
192
|
+
# Override some methods of ServerEngine::MultiSpawnWorker
|
193
|
+
# Since Fluentd's Supervisor doesn't use ServerEngine's HUP, USR1 and USR2
|
194
|
+
# handlers (see install_supervisor_signal_handlers), they should be
|
195
|
+
# disabled also on Windows, just send commands to workers instead.
|
196
|
+
def restart(graceful)
|
197
|
+
@monitors.each do |m|
|
198
|
+
m.send_command(graceful ? "GRACEFUL_RESTART\n" : "IMMEDIATE_RESTART\n")
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def reload
|
203
|
+
@monitors.each do |m|
|
204
|
+
m.send_command("RELOAD\n")
|
205
|
+
end
|
206
|
+
end
|
176
207
|
end
|
177
208
|
|
178
209
|
def install_windows_event_handler
|
210
|
+
return unless Fluent.windows?
|
211
|
+
|
212
|
+
@pid_signame = "fluentd_#{$$}"
|
213
|
+
@signame = config[:signame]
|
214
|
+
|
179
215
|
Thread.new do
|
180
|
-
|
216
|
+
ipc = Win32::Ipc.new(nil)
|
217
|
+
events = [
|
218
|
+
Win32::Event.new("#{@pid_signame}_STOP_EVENT_THREAD"),
|
219
|
+
Win32::Event.new("#{@pid_signame}"),
|
220
|
+
Win32::Event.new("#{@pid_signame}_HUP"),
|
221
|
+
Win32::Event.new("#{@pid_signame}_USR1"),
|
222
|
+
Win32::Event.new("#{@pid_signame}_USR2"),
|
223
|
+
]
|
224
|
+
if @signame
|
225
|
+
signame_events = [
|
226
|
+
Win32::Event.new("#{@signame}"),
|
227
|
+
Win32::Event.new("#{@signame}_HUP"),
|
228
|
+
Win32::Event.new("#{@signame}_USR1"),
|
229
|
+
Win32::Event.new("#{@signame}_USR2"),
|
230
|
+
]
|
231
|
+
events.concat(signame_events)
|
232
|
+
end
|
181
233
|
begin
|
182
|
-
|
183
|
-
|
184
|
-
|
234
|
+
loop do
|
235
|
+
idx = ipc.wait_any(events, Windows::Synchronize::INFINITE)
|
236
|
+
if idx > 0 && idx <= events.length
|
237
|
+
$log.debug("Got Win32 event \"#{events[idx - 1].name}\"")
|
238
|
+
else
|
239
|
+
$log.warn("Unexpected reutrn value of Win32::Ipc#wait_any: #{idx}")
|
240
|
+
end
|
241
|
+
case idx
|
242
|
+
when 2, 6
|
243
|
+
stop(true)
|
244
|
+
when 3, 7
|
245
|
+
supervisor_sighup_handler
|
246
|
+
when 4, 8
|
247
|
+
supervisor_sigusr1_handler
|
248
|
+
when 5, 9
|
249
|
+
supervisor_sigusr2_handler
|
250
|
+
when 1
|
251
|
+
break
|
252
|
+
end
|
185
253
|
end
|
186
|
-
kill_worker
|
187
|
-
stop(true)
|
188
254
|
ensure
|
189
|
-
|
255
|
+
events.each { |event| event.close }
|
190
256
|
end
|
191
257
|
end
|
192
258
|
end
|
193
259
|
|
260
|
+
def stop_windows_event_thread
|
261
|
+
if Fluent.windows?
|
262
|
+
ev = Win32::Event.open("#{@pid_signame}_STOP_EVENT_THREAD")
|
263
|
+
ev.set
|
264
|
+
ev.close
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
194
268
|
def supervisor_sighup_handler
|
195
269
|
kill_worker
|
196
270
|
end
|
@@ -265,9 +339,25 @@ module Fluent
|
|
265
339
|
def send_signal_to_workers(signal)
|
266
340
|
return unless config[:worker_pid]
|
267
341
|
|
268
|
-
|
269
|
-
|
270
|
-
|
342
|
+
if Fluent.windows?
|
343
|
+
send_command_to_workers(signal)
|
344
|
+
else
|
345
|
+
config[:worker_pid].each_value do |pid|
|
346
|
+
# don't rescue Errno::ESRCH here (invalid status)
|
347
|
+
Process.kill(signal, pid)
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
def send_command_to_workers(signal)
|
353
|
+
# Use SeverEngine's CommandSender on Windows
|
354
|
+
case signal
|
355
|
+
when :HUP
|
356
|
+
restart(false)
|
357
|
+
when :USR1
|
358
|
+
restart(true)
|
359
|
+
when :USR2
|
360
|
+
reload
|
271
361
|
end
|
272
362
|
end
|
273
363
|
end
|
@@ -302,6 +392,7 @@ module Fluent
|
|
302
392
|
log_level = params['log_level']
|
303
393
|
suppress_repeated_stacktrace = params['suppress_repeated_stacktrace']
|
304
394
|
ignore_repeated_log_interval = params['ignore_repeated_log_interval']
|
395
|
+
ignore_same_log_interval = params['ignore_same_log_interval']
|
305
396
|
|
306
397
|
log_path = params['log_path']
|
307
398
|
chuser = params['chuser']
|
@@ -309,7 +400,8 @@ module Fluent
|
|
309
400
|
log_rotate_age = params['log_rotate_age']
|
310
401
|
log_rotate_size = params['log_rotate_size']
|
311
402
|
|
312
|
-
log_opts = {suppress_repeated_stacktrace: suppress_repeated_stacktrace, ignore_repeated_log_interval: ignore_repeated_log_interval
|
403
|
+
log_opts = {suppress_repeated_stacktrace: suppress_repeated_stacktrace, ignore_repeated_log_interval: ignore_repeated_log_interval,
|
404
|
+
ignore_same_log_interval: ignore_same_log_interval}
|
313
405
|
logger_initializer = Supervisor::LoggerInitializer.new(
|
314
406
|
log_path, log_level, chuser, chgroup, log_opts,
|
315
407
|
log_rotate_age: log_rotate_age,
|
@@ -347,6 +439,7 @@ module Fluent
|
|
347
439
|
chumask: 0,
|
348
440
|
suppress_repeated_stacktrace: suppress_repeated_stacktrace,
|
349
441
|
ignore_repeated_log_interval: ignore_repeated_log_interval,
|
442
|
+
ignore_same_log_interval: ignore_same_log_interval,
|
350
443
|
daemonize: daemonize,
|
351
444
|
rpc_endpoint: params['rpc_endpoint'],
|
352
445
|
counter_server: params['counter_server'],
|
@@ -364,6 +457,7 @@ module Fluent
|
|
364
457
|
config_path: path,
|
365
458
|
main_cmd: params['main_cmd'],
|
366
459
|
signame: params['signame'],
|
460
|
+
disable_shared_socket: params['disable_shared_socket']
|
367
461
|
}
|
368
462
|
if daemonize
|
369
463
|
se_config[:pid_path] = pid_path
|
@@ -441,10 +535,11 @@ module Fluent
|
|
441
535
|
self
|
442
536
|
end
|
443
537
|
|
444
|
-
def apply_options(format: nil, time_format: nil, log_dir_perm: nil, ignore_repeated_log_interval: nil)
|
538
|
+
def apply_options(format: nil, time_format: nil, log_dir_perm: nil, ignore_repeated_log_interval: nil, ignore_same_log_interval: nil)
|
445
539
|
$log.format = format if format
|
446
540
|
$log.time_format = time_format if time_format
|
447
541
|
$log.ignore_repeated_log_interval = ignore_repeated_log_interval if ignore_repeated_log_interval
|
542
|
+
$log.ignore_same_log_interval = ignore_same_log_interval if ignore_same_log_interval
|
448
543
|
|
449
544
|
if @path && log_dir_perm
|
450
545
|
File.chmod(log_dir_perm || 0755, File.dirname(@path))
|
@@ -478,7 +573,8 @@ module Fluent
|
|
478
573
|
supervise: true,
|
479
574
|
standalone_worker: false,
|
480
575
|
signame: nil,
|
481
|
-
conf_encoding: 'utf-8'
|
576
|
+
conf_encoding: 'utf-8',
|
577
|
+
disable_shared_socket: nil
|
482
578
|
}
|
483
579
|
end
|
484
580
|
|
@@ -511,7 +607,8 @@ module Fluent
|
|
511
607
|
@cl_opt = opt
|
512
608
|
@conf = nil
|
513
609
|
|
514
|
-
log_opts = {suppress_repeated_stacktrace: opt[:suppress_repeated_stacktrace], ignore_repeated_log_interval: opt[:ignore_repeated_log_interval]
|
610
|
+
log_opts = {suppress_repeated_stacktrace: opt[:suppress_repeated_stacktrace], ignore_repeated_log_interval: opt[:ignore_repeated_log_interval],
|
611
|
+
ignore_same_log_interval: opt[:ignore_same_log_interval]}
|
515
612
|
@log = LoggerInitializer.new(
|
516
613
|
@log_path, opt[:log_level], @chuser, @chgroup, log_opts,
|
517
614
|
log_rotate_age: @log_rotate_age,
|
@@ -635,7 +732,8 @@ module Fluent
|
|
635
732
|
format: @system_config.log.format,
|
636
733
|
time_format: @system_config.log.time_format,
|
637
734
|
log_dir_perm: @system_config.dir_permission,
|
638
|
-
ignore_repeated_log_interval: @system_config.ignore_repeated_log_interval
|
735
|
+
ignore_repeated_log_interval: @system_config.ignore_repeated_log_interval,
|
736
|
+
ignore_same_log_interval: @system_config.ignore_same_log_interval
|
639
737
|
)
|
640
738
|
|
641
739
|
$log.info :supervisor, 'parsing config file is succeeded', path: @config_path
|
@@ -704,6 +802,7 @@ module Fluent
|
|
704
802
|
'counter_server' => @system_config.counter_server,
|
705
803
|
'log_format' => @system_config.log.format,
|
706
804
|
'log_time_format' => @system_config.log.time_format,
|
805
|
+
'disable_shared_socket' => @system_config.disable_shared_socket
|
707
806
|
}
|
708
807
|
|
709
808
|
se = ServerEngine.create(ServerModule, WorkerModule){
|
@@ -740,33 +839,45 @@ module Fluent
|
|
740
839
|
end
|
741
840
|
end
|
742
841
|
|
743
|
-
|
744
|
-
|
745
|
-
|
842
|
+
if Fluent.windows?
|
843
|
+
install_main_process_command_handlers
|
844
|
+
else
|
845
|
+
trap :USR1 do
|
846
|
+
flush_buffer
|
847
|
+
end
|
746
848
|
|
747
|
-
|
748
|
-
|
749
|
-
|
849
|
+
trap :USR2 do
|
850
|
+
reload_config
|
851
|
+
end
|
852
|
+
end
|
853
|
+
end
|
750
854
|
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
855
|
+
def install_main_process_command_handlers
|
856
|
+
command_pipe = $stdin.dup
|
857
|
+
$stdin.reopen(File::NULL, "rb")
|
858
|
+
command_pipe.binmode
|
859
|
+
command_pipe.sync = true
|
756
860
|
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
861
|
+
Thread.new do
|
862
|
+
loop do
|
863
|
+
cmd = command_pipe.gets
|
864
|
+
break unless cmd
|
865
|
+
|
866
|
+
case cmd.chomp!
|
867
|
+
when "GRACEFUL_STOP", "IMMEDIATE_STOP"
|
868
|
+
$log.debug "fluentd main process get #{cmd} command"
|
869
|
+
@finished = true
|
870
|
+
$log.debug "getting start to shutdown main process"
|
871
|
+
Fluent::Engine.stop
|
872
|
+
break
|
873
|
+
when "GRACEFUL_RESTART"
|
874
|
+
$log.debug "fluentd main process get #{cmd} command"
|
875
|
+
flush_buffer
|
876
|
+
when "RELOAD"
|
877
|
+
$log.debug "fluentd main process get #{cmd} command"
|
878
|
+
reload_config
|
879
|
+
else
|
880
|
+
$log.warn "fluentd main process get unknown command [#{cmd}]"
|
770
881
|
end
|
771
882
|
end
|
772
883
|
end
|