Skip to content

Commit

Permalink
Merge duplicated logic
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <[email protected]>
  • Loading branch information
ganmacs committed Dec 18, 2019
1 parent ffbf1c5 commit f1c23e0
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions lib/fluent/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,7 @@ def run
raise
end

unless @log_event_verbose
$log.enable_event(false)
@fluent_log_event_router.graceful_stop
end
$log.info "shutting down fluentd worker", worker: worker_id
shutdown

@fluent_log_event_router.stop
stop_phase(@root_agent)
end

# @param conf [Fluent::Config]
Expand All @@ -190,17 +183,9 @@ def reload_config(conf, supervisor: false)
return
end

# Stop phaze
unless @log_event_verbose
$log.enable_event(false)
@fluent_log_event_router.graceful_stop
end
$log.info 'shutting down fluentd worker', worker: worker_id
old_agent.shutdown # Stop first but we can still accept sockets, thanks to serverengine SocketManager,

@fluent_log_event_router.stop
stop_phase(old_agent)

# Restart phaze
# Restart phase
new_fleunt_log_event_router = FluentLogEventRouter.build(new_agent)
if new_fleunt_log_event_router.emittable?
$log.enable_event(true)
Expand Down Expand Up @@ -233,12 +218,20 @@ def worker_id
end

private
def start
@root_agent.start

def stop_phase(root_agent)
unless @log_event_verbose
$log.enable_event(false)
@fluent_log_event_router.graceful_stop
end
$log.info 'shutting down fluentd worker', worker: worker_id
root_agent.shutdown

@fluent_log_event_router.stop
end

def shutdown
@root_agent.shutdown
def start
@root_agent.start
end
end

Expand Down

0 comments on commit f1c23e0

Please sign in to comment.