-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
authored and
unknown
committed
Jul 17, 2013
1 parent
a4946e3
commit 81d6633
Showing
3 changed files
with
116 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
# | ||
module Fluent | ||
|
||
|
||
$usespawn = 0 | ||
This comment has been minimized.
Sorry, something went wrong.
repeatedly
Member
|
||
class Supervisor | ||
class LoggerInitializer | ||
def initialize(path, level, chuser, chgroup) | ||
|
@@ -69,7 +69,12 @@ def initialize(opt) | |
@inline_config = opt[:inline_config] | ||
@suppress_interval = opt[:suppress_interval] | ||
@dry_run = opt[:dry_run] | ||
$usespawn = opt[:usespawn] | ||
|
||
$platformwin = false | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/ | ||
$platformwin = true | ||
end | ||
@log = LoggerInitializer.new(@log_path, @log_level, @chuser, @chgroup) | ||
@finished = false | ||
@main_pid = nil | ||
|
@@ -168,9 +173,25 @@ def supervise(&block) | |
start_time = Time.now | ||
|
||
$log.info "starting fluentd-#{Fluent::VERSION}" | ||
$log.info "is windows platform : #{$platformwin}" | ||
|
||
if $platformwin == false | ||
@main_pid = fork do | ||
main_process(&block) | ||
end | ||
else | ||
if $usespawn == 0 then | ||
This comment has been minimized.
Sorry, something went wrong. |
||
flunetd_spawn_cmd = "fluentd " | ||
$fluentdargv.each{|a| | ||
flunetd_spawn_cmd << (a + " ") | ||
} | ||
flunetd_spawn_cmd << "-u" | ||
@main_pid = Process.spawn(flunetd_spawn_cmd) | ||
else | ||
@main_pid = Process.pid | ||
main_process(&block) | ||
end | ||
end | ||
|
||
if @daemonize && @wait_daemonize_pipe_w | ||
STDIN.reopen("/dev/null") | ||
|
@@ -180,7 +201,13 @@ def supervise(&block) | |
@wait_daemonize_pipe_w = nil | ||
end | ||
|
||
Process.waitpid(@main_pid) | ||
if $platform == false | ||
Process.waitpid(@main_pid) | ||
else | ||
if $usespawn == 0 | ||
Process.waitpid(@main_pid) | ||
end | ||
end | ||
@main_pid = nil | ||
ecode = $?.to_i | ||
|
||
|
@@ -249,25 +276,28 @@ def install_supervisor_signal_handlers | |
end | ||
end | ||
|
||
trap :HUP do | ||
$log.debug "fluentd supervisor process get SIGHUP" | ||
$log.info "restarting" | ||
if pid = @main_pid | ||
Process.kill(:TERM, pid) | ||
# don't resuce Erro::ESRSH here (invalid status) | ||
if $platformwin == false | ||
trap :HUP do | ||
$log.debug "fluentd supervisor process get SIGHUP" | ||
$log.info "restarting" | ||
if pid = @main_pid | ||
Process.kill(:TERM, pid) | ||
# don't resuce Erro::ESRSH here (invalid status) | ||
end | ||
end | ||
end | ||
|
||
trap :USR1 do | ||
$log.debug "fluentd supervisor process get SIGUSR1" | ||
@log.reopen! | ||
if pid = @main_pid | ||
Process.kill(:USR1, pid) | ||
# don't resuce Erro::ESRSH here (invalid status) | ||
if $platformwin == false | ||
trap :USR1 do | ||
$log.debug "fluentd supervisor process get SIGUSR1" | ||
@log.reopen! | ||
if pid = @main_pid | ||
Process.kill(:USR1, pid) | ||
# don't resuce Erro::ESRSH here (invalid status) | ||
end | ||
end | ||
end | ||
end | ||
|
||
def read_config | ||
$log.info "reading config file", :path=>@config_path | ||
@config_fname = File.basename(@config_path) | ||
|
@@ -356,16 +386,19 @@ def install_main_process_signal_handlers | |
end | ||
end | ||
|
||
trap :HUP do | ||
# TODO | ||
$log.debug "fluentd main process get SIGHUP" | ||
if $platformwin == false | ||
trap :HUP do | ||
# TODO | ||
$log.debug "fluentd main process get SIGHUP" | ||
end | ||
end | ||
|
||
trap :USR1 do | ||
$log.debug "fluentd main process get SIGUSR1" | ||
$log.info "force flushing buffered events" | ||
@log.reopen! | ||
Fluent::Engine.flush! | ||
if $platformwin == false | ||
trap :USR1 do | ||
$log.debug "fluentd main process get SIGUSR1" | ||
$log.info "force flushing buffered events" | ||
@log.reopen! | ||
Fluent::Engine.flush! | ||
end | ||
end | ||
end | ||
|
||
|
hoge == false
is redundant sounless $platform
or changing order ofif $platform
is better.