Skip to content

Commit

Permalink
no need to assign dry_run to ivar
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <[email protected]>
  • Loading branch information
ganmacs committed Oct 31, 2019
1 parent 6b64cfc commit 98e3034
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/command/fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@

supervisor = Fluent::Supervisor.new(opts)
supervisor.configure(supervisor: true)
supervisor.run_supervisor
supervisor.run_supervisor(dry_run: opts[:dry_run])
else
if opts[:standalone_worker] && opts[:workers] && opts[:workers] > 1
puts "Error: multi workers is not supported with --no-supervisor"
Expand Down
10 changes: 4 additions & 6 deletions lib/fluent/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ def initialize
@fluent_log_event_router = nil
@system_config = SystemConfig.new

@dry_run_mode = false
@supervisor_mode = false
end

MAINLOOP_SLEEP_INTERVAL = 0.3

attr_reader :root_agent, :system_config, :supervisor_mode, :dry_run_mode
attr_reader :root_agent, :system_config, :supervisor_mode

def init(system_config, supervisor_mode: false, dry_run_mode: false)
def init(system_config, supervisor_mode: false)
@system_config = system_config
@supervisor_mode = supervisor_mode
@dry_run_mode = dry_run_mode

@suppress_config_dump = system_config.suppress_config_dump unless system_config.suppress_config_dump.nil?
@without_source = system_config.without_source unless system_config.without_source.nil?
Expand All @@ -77,7 +75,7 @@ def parse_config(io, fname, basepath = Dir.pwd, v1_config = false)
end
end

def run_configure(conf)
def run_configure(conf, dry_run: false)
configure(conf)
conf.check_not_fetched do |key, e|
parent_name, plugin_name = e.unused_in
Expand All @@ -92,7 +90,7 @@ def run_configure(conf)
end
next if message.nil?

if @dry_run_mode && @supervisor_mode
if dry_run && @supervisor_mode
$log.warn :supervisor, message
elsif e.for_every_workers?
$log.warn :worker0, message
Expand Down
11 changes: 5 additions & 6 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ def initialize(opt)
@use_v1_config = opt[:use_v1_config]
@conf_encoding = opt[:conf_encoding]
@log_path = opt[:log_path]
@dry_run = opt[:dry_run]
@show_plugin_config = opt[:show_plugin_config]
@libs = opt[:libs]
@plugin_dirs = opt[:plugin_dirs]
Expand All @@ -473,8 +472,8 @@ def initialize(opt)
@finished = false
end

def run_supervisor
if @dry_run
def run_supervisor(dry_run: false)
if dry_run
$log.info "starting fluentd-#{Fluent::VERSION} as dry run mode", ruby: RUBY_VERSION
end

Expand All @@ -500,15 +499,15 @@ def run_supervisor
begin
ServerEngine::Privilege.change(@chuser, @chgroup)
MessagePackFactory.init
Fluent::Engine.init(@system_config, supervisor_mode: true, dry_run_mode: @dry_run)
Fluent::Engine.run_configure(@conf)
Fluent::Engine.init(@system_config, supervisor_mode: true)
Fluent::Engine.run_configure(@conf, dry_run: dry_run)
rescue Fluent::ConfigError => e
$log.error 'config error', file: @config_path, error: e
$log.debug_backtrace
exit!(1)
end

if @dry_run
if dry_run
$log.info 'finsihed dry run mode'
exit 0
else
Expand Down

0 comments on commit 98e3034

Please sign in to comment.