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

Add shutdown timeout #2514

Merged
merged 1 commit into from
Sep 12, 2016
Merged

Add shutdown timeout #2514

merged 1 commit into from
Sep 12, 2016

Conversation

urso
Copy link

@urso urso commented Sep 10, 2016

Introduce signalWait structure to filebeat waiting for stop signal after
fb.done was closed. If shutdown_timeout is configured, filebeat will either
stop after timeout or after all enqueued events have been successfully
published and written by registrar.

I hope the signalWait idea can be reused for implementing run-once mode as well.

@urso urso added discuss Issue needs further discussion. Filebeat Filebeat labels Sep 10, 2016
s.AddTimer(time.NewTimer(d))
}

func (s *signalWait) Signal() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for sending inserting a signal. E.g. having received Ctrl-C one can use Signal() to insert a signal into the waiter that triggers right now, such that Wait will not block.

e.g.

<- fb.done
if whatever {
    sigWait.Signal()
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

@ruflin ruflin mentioned this pull request Sep 12, 2016
2 tasks
Introduce signalWait structure to filebeat waiting for stop signal after
fb.done was closed. If shutdown_timeout is configured, filebeat will either
stop after timeout or after all enqueued events have been successfully
published and written by registrar.
@urso urso force-pushed the enh/filebeat-to-shutdown branch from ed4900b to 28e3906 Compare September 12, 2016 09:36
@urso urso added review and removed discuss Issue needs further discussion. labels Sep 12, 2016
@ruflin
Copy link
Contributor

ruflin commented Sep 12, 2016

LGTM

@@ -106,6 +125,12 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
// Blocks progressing. As soon as channel is closed, all defer statements come into play
<-fb.done

if fb.config.ShutdownTimeout > 0 {
// Wait for either timeout or all events having been ACKed by outputs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add here a log message that shutdown will wait for time X to shutdown or success

@ruflin ruflin merged commit d5135ac into elastic:master Sep 12, 2016
@urso urso deleted the enh/filebeat-to-shutdown branch February 19, 2019 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants