Skip to content

Commit

Permalink
Split RUBYOPT with space
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ganmacs committed Jan 31, 2020
1 parent ae8b374 commit f2eb1cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ def supervise

rubyopt = ENV["RUBYOPT"]
fluentd_spawn_cmd = [ServerEngine.ruby_bin_path, "-Eascii-8bit:ascii-8bit"]
fluentd_spawn_cmd << rubyopt if rubyopt
if rubyopt
fluentd_spawn_cmd.concat(rubyopt.split(' '))
end
fluentd_spawn_cmd << $0
fluentd_spawn_cmd += $fluentdargv
fluentd_spawn_cmd << "--under-supervisor"
Expand Down
29 changes: 23 additions & 6 deletions test/command/test_fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ def create_cmdline(conf_path, *fluentd_options)
["bundle", "exec", "ruby", cmd_path, "-c", conf_path, *fluentd_options]
end

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

env = {
"BUNDLE_GEMFILE" => gemfile_path,
}
env = { "BUNDLE_GEMFILE" => gemfile_path }.merge(env)
cmdname = cmdline.shift
arg0 = "testing-fluentd"
# p(here: "executing process", env: env, cmdname: cmdname, arg0: arg0, args: cmdline)
Expand All @@ -81,12 +79,12 @@ def execute_command(cmdline, chdir=TMP_DIR)
null_stream.close rescue nil
end

def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10)
def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10, env: {})
matched = false
assert_error_msg = "matched correctly"
stdio_buf = ""
begin
execute_command(cmdline) do |pid, stdout|
execute_command(cmdline, TMP_DIR, env) do |pid, stdout|
begin
waiting(timeout) do
while process_exist?(pid) && !matched
Expand Down Expand Up @@ -780,6 +778,25 @@ def multi_workers_ready?
)
end

test "multiple values are set to RUBYOPT" do
conf = <<CONF
<source>
@type dummy
tag dummy
</source>
<match>
@type null
</match>
CONF
conf_path = create_conf_file('rubyopt_test.conf', conf)
assert_log_matches(
create_cmdline(conf_path),
'#0 fluentd worker is now running worker=0',
patterns_not_match: ['(LoadError)'],
env: { 'RUBYOPT' => '-rtest-unit -rbundler/setup' },
)
end

test 'success to start workers when file buffer is configured in non-workers way only for specific worker' do
conf = <<CONF
<system>
Expand Down

0 comments on commit f2eb1cd

Please sign in to comment.