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

Use pipe command sender mechanism of ServerEngine on Windows #1171

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def self.load_config(path, params = {})
logger_initializer.init
logger = $log

command_sender = Fluent.windows? ? "pipe" : "signal"

# ServerEngine's "daemonize" option is boolean, and path of pid file is brought by "pid_path"
pid_path = params['daemonize']
daemonize = !!params['daemonize']
Expand Down Expand Up @@ -251,6 +253,7 @@ def self.load_config(path, params = {})
WorkerModule.name,
path,
JSON.dump(params)],
command_sender: command_sender,
fluentd_conf: fluentd_conf,
main_cmd: main_cmd,
}
Expand Down Expand Up @@ -528,6 +531,29 @@ def install_main_process_signal_handlers
trap :USR1 do
flush_buffer
end unless Fluent.windows?

if Fluent.windows?
command_pipe = STDIN.dup
STDIN.reopen(File::NULL, "rb")
command_pipe.binmode
command_pipe.sync = true

Thread.new do
loop do
cmd = command_pipe.gets.chomp
case cmd
when "GRACEFUL_STOP", "IMMEDIATE_STOP"
$log.debug "fluentd main process get #{cmd} command"
@finished = true
$log.debug "getting start to shutdown main process"
Fluent::Engine.stop
break
else
$log.warn "fluentd main process get unknown command [#{cmd}]"
end
end
end
end
end

def flush_buffer
Expand Down