Skip to content

Commit 4d47f7d

Browse files
committed
Split RUBYOPT with space
ruby seems not to have an option whose key and value are separated with space https://github.com/ruby/ruby/blob/3893a8dd42fb3bbd71750648c3c0de118955a6ea/ruby.c#L1028 Signed-off-by: Yuta Iwama <[email protected]>
1 parent ae8b374 commit 4d47f7d

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

lib/fluent/supervisor.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ def supervise
661661

662662
rubyopt = ENV["RUBYOPT"]
663663
fluentd_spawn_cmd = [ServerEngine.ruby_bin_path, "-Eascii-8bit:ascii-8bit"]
664-
fluentd_spawn_cmd << rubyopt if rubyopt
664+
if rubyopt
665+
fluentd_spawn_cmd.concat(rubyopt.split(' '))
666+
end
665667
fluentd_spawn_cmd << $0
666668
fluentd_spawn_cmd += $fluentdargv
667669
fluentd_spawn_cmd << "--under-supervisor"

test/command/test_fluentd.rb

+23-6
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def create_cmdline(conf_path, *fluentd_options)
5050
["bundle", "exec", "ruby", cmd_path, "-c", conf_path, *fluentd_options]
5151
end
5252

53-
def execute_command(cmdline, chdir=TMP_DIR)
53+
def execute_command(cmdline, chdir=TMP_DIR, env = {})
5454
null_stream = File.open(File::NULL, 'w')
5555
gemfile_path = File.expand_path(File.dirname(__FILE__) + "../../../Gemfile")
5656

57-
env = {
58-
"BUNDLE_GEMFILE" => gemfile_path,
59-
}
57+
env = { "BUNDLE_GEMFILE" => gemfile_path }.merge(env)
6058
cmdname = cmdline.shift
6159
arg0 = "testing-fluentd"
6260
# p(here: "executing process", env: env, cmdname: cmdname, arg0: arg0, args: cmdline)
@@ -81,12 +79,12 @@ def execute_command(cmdline, chdir=TMP_DIR)
8179
null_stream.close rescue nil
8280
end
8381

84-
def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10)
82+
def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10, env: {})
8583
matched = false
8684
assert_error_msg = "matched correctly"
8785
stdio_buf = ""
8886
begin
89-
execute_command(cmdline) do |pid, stdout|
87+
execute_command(cmdline, TMP_DIR, env) do |pid, stdout|
9088
begin
9189
waiting(timeout) do
9290
while process_exist?(pid) && !matched
@@ -780,6 +778,25 @@ def multi_workers_ready?
780778
)
781779
end
782780

781+
test "multiple values are set to RUBYOPT" do
782+
conf = <<CONF
783+
<source>
784+
@type dummy
785+
tag dummy
786+
</source>
787+
<match>
788+
@type null
789+
</match>
790+
CONF
791+
conf_path = create_conf_file('rubyopt_test.conf', conf)
792+
assert_log_matches(
793+
create_cmdline(conf_path),
794+
'#0 fluentd worker is now running worker=0',
795+
patterns_not_match: ['(LoadError)'],
796+
env: { 'RUBYOPT' => '-rtest-unit -ruri' },
797+
)
798+
end
799+
783800
test 'success to start workers when file buffer is configured in non-workers way only for specific worker' do
784801
conf = <<CONF
785802
<system>

0 commit comments

Comments
 (0)