fluentd 1.15.1-x86-mingw32 → 1.15.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -0
- data/fluentd.gemspec +0 -3
- data/lib/fluent/command/fluentd.rb +1 -17
- data/lib/fluent/config/yaml_parser/loader.rb +18 -1
- data/lib/fluent/file_wrapper.rb +137 -0
- data/lib/fluent/oj_options.rb +1 -2
- data/lib/fluent/plugin/in_tail.rb +1 -6
- data/lib/fluent/plugin/out_file.rb +0 -4
- data/lib/fluent/plugin_helper/child_process.rb +3 -0
- data/lib/fluent/supervisor.rb +47 -22
- data/lib/fluent/system_config.rb +2 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/win32api.rb +38 -0
- data/lib/fluent/winsvc.rb +3 -8
- data/test/command/test_fluentd.rb +31 -16
- data/test/config/test_system_config.rb +2 -0
- data/test/plugin/test_in_tail.rb +105 -103
- data/test/plugin/test_out_file.rb +3 -2
- data/test/test_config.rb +57 -0
- data/test/{plugin/test_file_wrapper.rb → test_file_wrapper.rb} +2 -7
- data/test/test_log.rb +15 -5
- data/test/test_supervisor.rb +37 -15
- metadata +7 -56
- data/.github/workflows/issue-auto-closer.yml +0 -12
- data/.github/workflows/stale-actions.yml +0 -22
- data/lib/fluent/plugin/file_wrapper.rb +0 -132
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126fe0c708fd1841d5b8d6eb273ccb15a88c68b255efb039a4b3669283e98db8
|
4
|
+
data.tar.gz: 9a90482923948c6b29f6628a1854db956e6838f54a281e4627497f8e9acd67c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c264bdc02ff8b848adc83b7203e1740eed9e99ed310b0162c0d1ef9512e2152641ebbccb435a0b47b98137c859f9e9eaf499f823f377fa178ac61b2581f001
|
7
|
+
data.tar.gz: 76c22db82d0b74b866fe1042d57703e8ea26fed3c8572ea730bfd8f3eb96137b9f10027b31179ad9bf01b5f4e074585e63940d43c64076f2ddcc7e1a1b2ef034
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,44 @@
|
|
1
1
|
# v1.15
|
2
2
|
|
3
|
+
## Release v1.15.3 - 2022/11/02
|
4
|
+
|
5
|
+
### Bug Fix
|
6
|
+
|
7
|
+
* Support glob for `!include` directive in YAML config format
|
8
|
+
https://github.com/fluent/fluentd/pull/3917
|
9
|
+
* Remove meaningless oj options
|
10
|
+
https://github.com/fluent/fluentd/pull/3929
|
11
|
+
* Fix log initializer to correctly create per-process files on Windows
|
12
|
+
https://github.com/fluent/fluentd/pull/3939
|
13
|
+
* out_file: Fix the multi-worker check with `<worker 0-N>` directive
|
14
|
+
https://github.com/fluent/fluentd/pull/3942
|
15
|
+
|
16
|
+
### Misc
|
17
|
+
|
18
|
+
* Fix broken tests on Ruby 3.2
|
19
|
+
https://github.com/fluent/fluentd/pull/3883
|
20
|
+
https://github.com/fluent/fluentd/pull/3922
|
21
|
+
|
22
|
+
## Release v1.15.2 - 2022/08/22
|
23
|
+
|
24
|
+
### Enhancement
|
25
|
+
|
26
|
+
* Add a new system configuration `enable_jit`
|
27
|
+
https://github.com/fluent/fluentd/pull/3857
|
28
|
+
|
29
|
+
### Bug Fix
|
30
|
+
|
31
|
+
* out_file: Fix append mode with `--daemon` flag
|
32
|
+
https://github.com/fluent/fluentd/pull/3864
|
33
|
+
* child_process: Plug file descriptor leak
|
34
|
+
https://github.com/fluent/fluentd/pull/3844
|
35
|
+
|
36
|
+
### Misc
|
37
|
+
|
38
|
+
* Drop win32-api gem to support Ruby 3.2
|
39
|
+
https://github.com/fluent/fluentd/pull/3849
|
40
|
+
https://github.com/fluent/fluentd/pull/3866
|
41
|
+
|
3
42
|
## Release v1.15.1 - 2022/07/27
|
4
43
|
|
5
44
|
### Bug Fix
|
data/fluentd.gemspec
CHANGED
@@ -34,12 +34,9 @@ Gem::Specification.new do |gem|
|
|
34
34
|
fake_platform = ENV['GEM_BUILD_FAKE_PLATFORM'].to_s
|
35
35
|
gem.platform = fake_platform unless fake_platform.empty?
|
36
36
|
if /mswin|mingw/ =~ fake_platform || (/mswin|mingw/ =~ RUBY_PLATFORM && fake_platform.empty?)
|
37
|
-
gem.add_runtime_dependency("win32-api", [">= 1.10", "< 2.0.0"])
|
38
37
|
gem.add_runtime_dependency("win32-service", ["~> 2.3.0"])
|
39
38
|
gem.add_runtime_dependency("win32-ipc", ["~> 0.7.0"])
|
40
39
|
gem.add_runtime_dependency("win32-event", ["~> 0.6.3"])
|
41
|
-
gem.add_runtime_dependency("windows-api", ["~> 0.4.5"])
|
42
|
-
gem.add_runtime_dependency("windows-pr", ["~> 1.2.6"])
|
43
40
|
gem.add_runtime_dependency("certstore_c", ["~> 0.1.7"])
|
44
41
|
end
|
45
42
|
|
@@ -189,9 +189,6 @@ op.on('--disable-shared-socket', "Don't open shared socket for multiple workers"
|
|
189
189
|
}
|
190
190
|
|
191
191
|
if Fluent.windows?
|
192
|
-
require 'windows/library'
|
193
|
-
include Windows::Library
|
194
|
-
|
195
192
|
opts.merge!(
|
196
193
|
:winsvc_name => 'fluentdwinsvc',
|
197
194
|
:winsvc_display_name => 'Fluentd Windows Service',
|
@@ -292,9 +289,7 @@ if winsvcinstmode = opts[:regwinsvc]
|
|
292
289
|
case winsvcinstmode
|
293
290
|
when 'i'
|
294
291
|
binary_path = File.join(File.dirname(__FILE__), "..")
|
295
|
-
ruby_path =
|
296
|
-
GetModuleFileName.call(0,ruby_path,256)
|
297
|
-
ruby_path = ruby_path.rstrip.gsub(/\\/, '/')
|
292
|
+
ruby_path = ServerEngine.ruby_bin_path
|
298
293
|
start_type = Service::DEMAND_START
|
299
294
|
if opts[:regwinsvcautostart]
|
300
295
|
start_type = Service::AUTO_START
|
@@ -350,17 +345,6 @@ end
|
|
350
345
|
exit 0 if early_exit
|
351
346
|
|
352
347
|
if opts[:supervise]
|
353
|
-
if Fluent.windows?
|
354
|
-
if opts[:log_path] && opts[:log_path] != "-"
|
355
|
-
if opts[:log_rotate_age] || opts[:log_rotate_size]
|
356
|
-
require 'pathname'
|
357
|
-
|
358
|
-
log_path = Pathname(opts[:log_path]).sub_ext("-supervisor#{Pathname(opts[:log_path]).extname}").to_s
|
359
|
-
opts[:log_path] = log_path
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
348
|
supervisor = Fluent::Supervisor.new(opts)
|
365
349
|
supervisor.configure(supervisor: true)
|
366
350
|
supervisor.run_supervisor(dry_run: opts[:dry_run])
|
@@ -44,7 +44,7 @@ module Fluent
|
|
44
44
|
visitor = Visitor.new(scanner, class_loader)
|
45
45
|
|
46
46
|
visitor._register_domain(INCLUDE_TAG) do |_, val|
|
47
|
-
|
47
|
+
eval_include(Pathname.new(val), path.parent)
|
48
48
|
end
|
49
49
|
|
50
50
|
visitor._register_domain(FLUENT_JSON_TAG) do |_, val|
|
@@ -60,6 +60,23 @@ module Fluent
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def eval_include(path, parent)
|
64
|
+
if path.relative?
|
65
|
+
pattern = parent.join(path)
|
66
|
+
else
|
67
|
+
pattern = path
|
68
|
+
end
|
69
|
+
result = []
|
70
|
+
Dir.glob(pattern).sort.each do |path|
|
71
|
+
result.concat(load(Pathname.new(path)))
|
72
|
+
end
|
73
|
+
result
|
74
|
+
rescue SystemCallError => e
|
75
|
+
parse_error = ConfigParseError.new("include error #{path} - #{e}")
|
76
|
+
parse_error.set_backtrace(e.backtrace)
|
77
|
+
raise parse_error
|
78
|
+
end
|
79
|
+
|
63
80
|
class Visitor < Psych::Visitors::ToRuby
|
64
81
|
def initialize(scanner, class_loader)
|
65
82
|
super(scanner, class_loader)
|
@@ -0,0 +1,137 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
unless Fluent.windows?
|
18
|
+
Fluent::FileWrapper = File
|
19
|
+
else
|
20
|
+
require 'fluent/win32api'
|
21
|
+
|
22
|
+
module Fluent
|
23
|
+
module FileWrapper
|
24
|
+
def self.open(path, mode='r')
|
25
|
+
io = WindowsFile.new(path, mode).io
|
26
|
+
if block_given?
|
27
|
+
v = yield io
|
28
|
+
io.close
|
29
|
+
v
|
30
|
+
else
|
31
|
+
io
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.stat(path)
|
36
|
+
f = WindowsFile.new(path)
|
37
|
+
s = f.stat
|
38
|
+
f.close
|
39
|
+
s
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class WindowsFile
|
44
|
+
include File::Constants
|
45
|
+
|
46
|
+
attr_reader :io
|
47
|
+
|
48
|
+
INVALID_HANDLE_VALUE = -1
|
49
|
+
|
50
|
+
def initialize(path, mode_enc='r')
|
51
|
+
@path = path
|
52
|
+
mode, enc = mode_enc.split(":", 2)
|
53
|
+
@io = File.open(path, mode2flags(mode))
|
54
|
+
@io.set_encoding(enc) if enc
|
55
|
+
@file_handle = Win32API._get_osfhandle(@io.to_i)
|
56
|
+
@io.instance_variable_set(:@file_index, self.ino)
|
57
|
+
def @io.ino
|
58
|
+
@file_index
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def close
|
63
|
+
@io.close
|
64
|
+
@file_handle = INVALID_HANDLE_VALUE
|
65
|
+
end
|
66
|
+
|
67
|
+
# To keep backward compatibility, we continue to use GetFileInformationByHandle()
|
68
|
+
# to get file id.
|
69
|
+
# Note that Ruby's File.stat uses GetFileInformationByHandleEx() with FileIdInfo
|
70
|
+
# and returned value is different with above one, former one is 64 bit while
|
71
|
+
# later one is 128bit.
|
72
|
+
def ino
|
73
|
+
by_handle_file_information = '\0'*(4+8+8+8+4+4+4+4+4+4) #72bytes
|
74
|
+
|
75
|
+
unless Win32API.GetFileInformationByHandle(@file_handle, by_handle_file_information)
|
76
|
+
return 0
|
77
|
+
end
|
78
|
+
|
79
|
+
by_handle_file_information.unpack("I11Q1")[11] # fileindex
|
80
|
+
end
|
81
|
+
|
82
|
+
def stat
|
83
|
+
raise Errno::ENOENT if delete_pending
|
84
|
+
s = File.stat(@path)
|
85
|
+
s.instance_variable_set :@ino, self.ino
|
86
|
+
def s.ino; @ino; end
|
87
|
+
s
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def mode2flags(mode)
|
93
|
+
# Always inject File::Constants::SHARE_DELETE
|
94
|
+
# https://github.com/fluent/fluentd/pull/3585#issuecomment-1101502617
|
95
|
+
# To enable SHARE_DELETE, BINARY is also required.
|
96
|
+
# https://bugs.ruby-lang.org/issues/11218
|
97
|
+
# https://github.com/ruby/ruby/blob/d6684f063bc53e3cab025bd39526eca3b480b5e7/win32/win32.c#L6332-L6345
|
98
|
+
flags = BINARY | SHARE_DELETE
|
99
|
+
case mode.delete("b")
|
100
|
+
when "r"
|
101
|
+
flags |= RDONLY
|
102
|
+
when "r+"
|
103
|
+
flags |= RDWR
|
104
|
+
when "w"
|
105
|
+
flags |= WRONLY | CREAT | TRUNC
|
106
|
+
when "w+"
|
107
|
+
flags |= RDWR | CREAT | TRUNC
|
108
|
+
when "a"
|
109
|
+
flags |= WRONLY | CREAT | APPEND
|
110
|
+
when "a+"
|
111
|
+
flags |= RDWR | CREAT | APPEND
|
112
|
+
else
|
113
|
+
raise Errno::EINVAL.new("Unsupported mode by Fluent::FileWrapper: #{mode}")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# DeletePending is a Windows-specific file state that roughly means
|
118
|
+
# "this file is queued for deletion, so close any open handlers"
|
119
|
+
#
|
120
|
+
# This flag can be retrieved via GetFileInformationByHandleEx().
|
121
|
+
#
|
122
|
+
# https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getfileinformationbyhandleex
|
123
|
+
#
|
124
|
+
def delete_pending
|
125
|
+
file_standard_info = 0x01
|
126
|
+
bufsize = 1024
|
127
|
+
buf = '\0' * bufsize
|
128
|
+
|
129
|
+
unless Win32API.GetFileInformationByHandleEx(@file_handle, file_standard_info, buf, bufsize)
|
130
|
+
return false
|
131
|
+
end
|
132
|
+
|
133
|
+
return buf.unpack("QQICC")[3] != 0
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/lib/fluent/oj_options.rb
CHANGED
@@ -4,14 +4,13 @@ module Fluent
|
|
4
4
|
class OjOptions
|
5
5
|
OPTIONS = {
|
6
6
|
'bigdecimal_load': :symbol,
|
7
|
-
'max_nesting': :integer,
|
8
7
|
'mode': :symbol,
|
9
8
|
'use_to_json': :bool
|
10
9
|
}
|
11
10
|
|
12
11
|
ALLOWED_VALUES = {
|
13
12
|
'bigdecimal_load': %i[bigdecimal float auto],
|
14
|
-
'mode': %i[strict null compat json rails
|
13
|
+
'mode': %i[strict null compat json rails custom]
|
15
14
|
}
|
16
15
|
|
17
16
|
DEFAULTS = {
|
@@ -25,12 +25,7 @@ require 'fluent/variable_store'
|
|
25
25
|
require 'fluent/capability'
|
26
26
|
require 'fluent/plugin/in_tail/position_file'
|
27
27
|
require 'fluent/plugin/in_tail/group_watch'
|
28
|
-
|
29
|
-
if Fluent.windows?
|
30
|
-
require_relative 'file_wrapper'
|
31
|
-
else
|
32
|
-
Fluent::FileWrapper = File
|
33
|
-
end
|
28
|
+
require 'fluent/file_wrapper'
|
34
29
|
|
35
30
|
module Fluent::Plugin
|
36
31
|
class TailInput < Fluent::Plugin::Input
|
@@ -188,10 +188,6 @@ module Fluent::Plugin
|
|
188
188
|
condition = Gem::Dependency.new('', [">= 2.7.0", "< 3.1.0"])
|
189
189
|
@need_ruby_on_macos_workaround = true if condition.match?('', RUBY_VERSION)
|
190
190
|
end
|
191
|
-
|
192
|
-
if @need_lock && @append && @fluentd_lock_dir.nil?
|
193
|
-
raise Fluent::InvalidLockDirectory, "must set FLUENTD_LOCK_DIR on multi-worker append mode"
|
194
|
-
end
|
195
191
|
end
|
196
192
|
|
197
193
|
def multi_workers_ready?
|
@@ -346,6 +346,9 @@ module Fluent
|
|
346
346
|
if cb
|
347
347
|
cb.call(process_info.exit_status) rescue nil
|
348
348
|
end
|
349
|
+
process_info.readio&.close rescue nil
|
350
|
+
process_info.writeio&.close rescue nil
|
351
|
+
process_info.stderrio&.close rescue nil
|
349
352
|
end
|
350
353
|
thread[:_fluentd_plugin_helper_child_process_running] = true
|
351
354
|
thread[:_fluentd_plugin_helper_child_process_pid] = pid
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -32,12 +32,6 @@ require 'fluent/variable_store'
|
|
32
32
|
require 'serverengine'
|
33
33
|
|
34
34
|
if Fluent.windows?
|
35
|
-
require 'windows/library'
|
36
|
-
require 'windows/synchronize'
|
37
|
-
require 'windows/system_info'
|
38
|
-
include Windows::Library
|
39
|
-
include Windows::Synchronize
|
40
|
-
include Windows::SystemInfo
|
41
35
|
require 'win32/ipc'
|
42
36
|
require 'win32/event'
|
43
37
|
end
|
@@ -50,6 +44,9 @@ module Fluent
|
|
50
44
|
@rpc_server = nil
|
51
45
|
@counter = nil
|
52
46
|
|
47
|
+
@fluentd_lock_dir = Dir.mktmpdir("fluentd-lock-")
|
48
|
+
ENV['FLUENTD_LOCK_DIR'] = @fluentd_lock_dir
|
49
|
+
|
53
50
|
if config[:rpc_endpoint]
|
54
51
|
@rpc_endpoint = config[:rpc_endpoint]
|
55
52
|
@enable_get_dump = config[:enable_get_dump]
|
@@ -79,9 +76,15 @@ module Fluent
|
|
79
76
|
stop_windows_event_thread if Fluent.windows?
|
80
77
|
stop_rpc_server if @rpc_endpoint
|
81
78
|
stop_counter_server if @counter
|
79
|
+
cleanup_lock_dir
|
82
80
|
Fluent::Supervisor.cleanup_resources
|
83
81
|
end
|
84
82
|
|
83
|
+
def cleanup_lock_dir
|
84
|
+
FileUtils.rm(Dir.glob(File.join(@fluentd_lock_dir, "fluentd-*.lock")))
|
85
|
+
FileUtils.rmdir(@fluentd_lock_dir)
|
86
|
+
end
|
87
|
+
|
85
88
|
def run_rpc_server
|
86
89
|
@rpc_server = RPC::Server.new(@rpc_endpoint, $log)
|
87
90
|
|
@@ -235,7 +238,8 @@ module Fluent
|
|
235
238
|
end
|
236
239
|
begin
|
237
240
|
loop do
|
238
|
-
|
241
|
+
infinite = 0xFFFFFFFF
|
242
|
+
ipc_idx = ipc.wait_any(events.map {|e| e[:win32_event]}, infinite)
|
239
243
|
event_idx = ipc_idx - 1
|
240
244
|
|
241
245
|
if event_idx >= 0 && event_idx < events.length
|
@@ -521,10 +525,22 @@ module Fluent
|
|
521
525
|
@log_rotate_size = log_rotate_size
|
522
526
|
end
|
523
527
|
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
+
# Create a unique path for each process.
|
529
|
+
#
|
530
|
+
# >>> per_process_path(:worker, 1, "C:/tmp/test.log")
|
531
|
+
# C:/tmp/test-1.log
|
532
|
+
# >>> per_process_path(:supervisor, 0, "C:/tmp/test.log")
|
533
|
+
# C:/tmp/test-supervisor-0.log
|
534
|
+
def self.per_process_path(path, process_type, worker_id)
|
535
|
+
path = Pathname(path)
|
536
|
+
ext = path.extname
|
537
|
+
|
538
|
+
if process_type == :supervisor
|
539
|
+
suffix = "-#{process_type}-0#{ext}" # "-0" for backword compatibility.
|
540
|
+
else
|
541
|
+
suffix = "-#{worker_id}#{ext}"
|
542
|
+
end
|
543
|
+
return path.sub_ext(suffix).to_s
|
528
544
|
end
|
529
545
|
|
530
546
|
def init(process_type, worker_id)
|
@@ -536,13 +552,19 @@ module Fluent
|
|
536
552
|
FileUtils.mkdir_p(File.dirname(@path))
|
537
553
|
end
|
538
554
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
555
|
+
if @log_rotate_age || @log_rotate_size
|
556
|
+
# We need to prepare a unique path for each worker since
|
557
|
+
# Windows locks files.
|
558
|
+
if Fluent.windows?
|
559
|
+
path = LoggerInitializer.per_process_path(@path, process_type, worker_id)
|
560
|
+
else
|
561
|
+
path = @path
|
562
|
+
end
|
563
|
+
@logdev = Fluent::LogDeviceIO.new(path, shift_age: @log_rotate_age, shift_size: @log_rotate_size)
|
564
|
+
else
|
565
|
+
@logdev = File.open(@path, "a")
|
566
|
+
end
|
567
|
+
|
546
568
|
if @chuser || @chgroup
|
547
569
|
chuid = @chuser ? ServerEngine::Privilege.get_etc_passwd(@chuser).uid : nil
|
548
570
|
chgid = @chgroup ? ServerEngine::Privilege.get_etc_group(@chgroup).gid : nil
|
@@ -561,6 +583,7 @@ module Fluent
|
|
561
583
|
$log = Fluent::Log.new(logger, @opts)
|
562
584
|
$log.enable_color(false) if @path
|
563
585
|
$log.enable_debug if @level <= Fluent::Log::LEVEL_DEBUG
|
586
|
+
$log.info "init #{process_type} logger", path: path, rotate_age: @log_rotate_age, rotate_size: @log_rotate_size
|
564
587
|
end
|
565
588
|
|
566
589
|
def stdout?
|
@@ -876,10 +899,7 @@ module Fluent
|
|
876
899
|
Fluent::Supervisor.load_config(@config_path, params)
|
877
900
|
}
|
878
901
|
|
879
|
-
|
880
|
-
ENV['FLUENTD_LOCK_DIR'] = lock_dir
|
881
|
-
se.run
|
882
|
-
end
|
902
|
+
se.run
|
883
903
|
end
|
884
904
|
|
885
905
|
def install_main_process_signal_handlers
|
@@ -1104,6 +1124,11 @@ module Fluent
|
|
1104
1124
|
fluentd_spawn_cmd << '-Eascii-8bit:ascii-8bit'
|
1105
1125
|
end
|
1106
1126
|
|
1127
|
+
if @system_config.enable_jit
|
1128
|
+
$log.info "enable Ruby JIT for workers (--jit)"
|
1129
|
+
fluentd_spawn_cmd << '--jit'
|
1130
|
+
end
|
1131
|
+
|
1107
1132
|
# Adding `-h` so that it can avoid ruby's command blocking
|
1108
1133
|
# e.g. `ruby -Eascii-8bit:ascii-8bit` will block. but `ruby -Eascii-8bit:ascii-8bit -h` won't.
|
1109
1134
|
_, e, s = Open3.capture3(*fluentd_spawn_cmd, "-h")
|
data/lib/fluent/system_config.rb
CHANGED
@@ -28,7 +28,7 @@ module Fluent
|
|
28
28
|
:without_source, :rpc_endpoint, :enable_get_dump, :process_name,
|
29
29
|
:file_permission, :dir_permission, :counter_server, :counter_client,
|
30
30
|
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket,
|
31
|
-
:metrics, :enable_input_metrics, :enable_size_metrics
|
31
|
+
:metrics, :enable_input_metrics, :enable_size_metrics, :enable_jit
|
32
32
|
]
|
33
33
|
|
34
34
|
config_param :workers, :integer, default: 1
|
@@ -50,6 +50,7 @@ module Fluent
|
|
50
50
|
config_param :disable_shared_socket, :bool, default: nil
|
51
51
|
config_param :enable_input_metrics, :bool, default: nil
|
52
52
|
config_param :enable_size_metrics, :bool, default: nil
|
53
|
+
config_param :enable_jit, :bool, default: false
|
53
54
|
config_param :file_permission, default: nil do |v|
|
54
55
|
v.to_i(8)
|
55
56
|
end
|
data/lib/fluent/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/env'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
module Win32API
|
21
|
+
require 'fiddle/import'
|
22
|
+
require 'fiddle/types'
|
23
|
+
extend Fiddle::Importer
|
24
|
+
|
25
|
+
if RUBY_PLATFORM.split('-')[-1] == "ucrt"
|
26
|
+
MSVCRT_DLL = 'ucrtbase.dll'
|
27
|
+
else
|
28
|
+
MSVCRT_DLL = 'msvcrt.dll'
|
29
|
+
end
|
30
|
+
|
31
|
+
dlload MSVCRT_DLL, "kernel32.dll"
|
32
|
+
include Fiddle::Win32Types
|
33
|
+
|
34
|
+
extern "intptr_t _get_osfhandle(int)"
|
35
|
+
extern "BOOL GetFileInformationByHandle(HANDLE, void *)"
|
36
|
+
extern "BOOL GetFileInformationByHandleEx(HANDLE, int, void *, DWORD)"
|
37
|
+
end if Fluent.windows?
|
38
|
+
end
|
data/lib/fluent/winsvc.rb
CHANGED
@@ -17,14 +17,12 @@
|
|
17
17
|
begin
|
18
18
|
|
19
19
|
require 'optparse'
|
20
|
-
require 'windows/debug'
|
21
|
-
require 'Windows/Library'
|
22
20
|
require 'win32/daemon'
|
23
21
|
require 'win32/event'
|
22
|
+
require 'win32/registry'
|
23
|
+
require 'serverengine'
|
24
24
|
|
25
25
|
include Win32
|
26
|
-
include Windows::Library
|
27
|
-
include Windows::Debug
|
28
26
|
|
29
27
|
op = OptionParser.new
|
30
28
|
opts = {service_name: nil}
|
@@ -37,16 +35,13 @@ begin
|
|
37
35
|
end
|
38
36
|
|
39
37
|
def read_fluentdopt(service_name)
|
40
|
-
require 'win32/Registry'
|
41
38
|
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\#{service_name}") do |reg|
|
42
39
|
reg.read("fluentdopt")[1] rescue ""
|
43
40
|
end
|
44
41
|
end
|
45
42
|
|
46
43
|
def service_main_start(service_name)
|
47
|
-
ruby_path =
|
48
|
-
GetModuleFileName.call(0, ruby_path,260)
|
49
|
-
ruby_path = ruby_path.rstrip.gsub(/\\/, '/')
|
44
|
+
ruby_path = ServerEngine.ruby_bin_path
|
50
45
|
rubybin_dir = ruby_path[0, ruby_path.rindex("/")]
|
51
46
|
opt = read_fluentdopt(service_name)
|
52
47
|
Process.spawn("\"#{rubybin_dir}/ruby.exe\" \"#{rubybin_dir}/fluentd\" #{opt} -x #{service_name}")
|