Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supervisor spawn does not carry forward any ruby options passed #1042

Closed
larsf opened this issue Jun 7, 2016 · 5 comments
Closed

supervisor spawn does not carry forward any ruby options passed #1042

larsf opened this issue Jun 7, 2016 · 5 comments
Assignees
Labels

Comments

@larsf
Copy link

larsf commented Jun 7, 2016

In fluentd 0.12 it simply forked itself, and so it was a clone of the process starting up:

@main_pid = fork do
main_process(&block)
end

In fluentd 0.14 it now builds its own exec command and spawns a new process using server engine:
fluentd_spawn_cmd = ServerEngine.ruby_bin_path + " -Eascii-8bit:ascii-8bit "
fluentd_spawn_cmd << $0.shellescape + ' '
$fluentdargv.each{|a|
fluentd_spawn_cmd << (a.shellescape + " ")
}
end

  fluentd_spawn_cmd << ("--no-supervisor")
  $log.info "spawn command to main: " + fluentd_spawn_cmd

  params = {}
  params['main_cmd'] = fluentd_spawn_cmd

Any ruby parameters are lost this way:

If you used bundler with fluentd, the first process that started would get started using:
ruby -r bundler/setup

the -r bundler/setup does not get passed for the command line for the server engine spawn, and the second fluentd process no longer finds the gems it is bundled with, and you will see a lot of this during startup:

016-06-07 15:41:19 -0700 [info]: reading config file path="../etc/fluentd/fluentd.conf"
2016-06-07 15:41:19 -0700 [info]: starting fluentd-0.14.0
2016-06-07 15:41:19 -0700 [info]: spawn command to main: /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/bin/ruby -Eascii-8bit:ascii-8bit /opt/mapr/fluentd/fluentd-0.14.00/bin/../lib/fluentd-0.14.00-linux-x86_64/lib/app/bin/fluentd -c ../etc/fluentd/fluentd.conf --no-supervisor
/opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- yajl (LoadError) from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/app/lib/fluent/config/literal_parser.rb:20:in <top (required)>' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/app/lib/fluent/config/element.rb:18:in<top (required)>'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/app/lib/fluent/config.rb:18:in <top (required)>' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/app/lib/fluent/supervisor.rb:20:in<top (required)>'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/app/lib/fluent/command/fluentd.rb:19:in <top (required)>' from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /opt/mapr/fluentd/fluentd-0.14.00/lib/fluentd-0.14.00-linux-x86_64/lib/ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/mapr/fluentd/fluentd-0.14.00/bin/../lib/fluentd-0.14.00-linux-x86_64/lib/app/bin/fluentd:5:in

'
2016-06-07 15:41:19 -0700 [info]: Worker 0 finished unexpectedly with status 1

Adding "-rbundler/setup" to the fluentd_spawn_cmd in app/lib/fluent/supervisor.rb like this:
fluentd_spawn_cmd = ServerEngine.ruby_bin_path + " -Eascii-8bit:ascii-8bit -rbundler/setup "

fixes it, but a more generic solution is required to preserve the ruby options give at start of the original process

@repeatedly
Copy link
Member

@naritta Could you check this?

@naritta
Copy link
Member

naritta commented Jun 23, 2016

@tagomoris @repeatedly
Is it assumed to use RUBYOPT from command line in fluentd and do we need to pass it to worker process?
If so, I'll fix soon.

@tagomoris
Copy link
Member

Yes, it looks work fine > RUBYOPT
I think it's the best to announce to use RUBYOPT for options of ruby, and to fix supervisor.rb to propagate RUBYOPT to worker processes.

@naritta
Copy link
Member

naritta commented Jun 23, 2016

Thank you for the comment.
I'll fix in #1066

@repeatedly
Copy link
Member

We just merged the patch.
We will release v0.14.1 soon so please wait...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants