From 8e2c38fb401801e15665ab4e81760ab360d8f45f Mon Sep 17 00:00:00 2001 From: "GOOGLE\\talarico" Date: Tue, 11 Apr 2017 08:46:27 -0700 Subject: [PATCH] Quote file paths to the ruby bin directory when starting fluentd as a windows service. The the file path is passed to win32-service (which calls windows functions CreateService[1]) and to Process.spawn [2]. Both require spaces to be wrapped in quotes or windows will not properly handle them. Without this fix fluentd will fail fail when initilizing or when starting. [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682450(v=vs.85).aspx [2]: https://ruby-doc.org/core-2.2.0/Process.html#method-c-spawn --- lib/fluent/command/fluentd.rb | 2 +- lib/fluent/winsvc.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fluent/command/fluentd.rb b/lib/fluent/command/fluentd.rb index d8707b7bcd..4cda843746 100644 --- a/lib/fluent/command/fluentd.rb +++ b/lib/fluent/command/fluentd.rb @@ -256,7 +256,7 @@ description: FLUENTD_WINSVC_DESC, start_type: start_type, error_control: Service::ERROR_NORMAL, - binary_path_name: ruby_path+" -C "+binary_path+" winsvc.rb", + binary_path_name: "\"#{ruby_path}\" -C \"#{binary_path}\" winsvc.rb", load_order_group: "", dependencies: [""], display_name: FLUENTD_WINSVC_DISPLAYNAME diff --git a/lib/fluent/winsvc.rb b/lib/fluent/winsvc.rb index 97eaf34f2f..ecb0ff9451 100644 --- a/lib/fluent/winsvc.rb +++ b/lib/fluent/winsvc.rb @@ -40,7 +40,7 @@ def service_main_start ruby_path = ruby_path.rstrip.gsub(/\\/, '/') rubybin_dir = ruby_path[0, ruby_path.rindex("/")] opt = read_fluentdopt - Process.spawn(rubybin_dir + "/ruby.exe " + rubybin_dir + "/fluentd " + opt + " -x " + INTEVENTOBJ_NAME) + Process.spawn("\"#{rubybin_dir}/ruby.exe\" \"#{rubybin_dir}/fluentd\" #{opt} -x #{INTEVENTOBJ_NAME}") end class FluentdService < Daemon