-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add shutdown timeout #2514
Conversation
s.AddTimer(time.NewTimer(d)) | ||
} | ||
|
||
func (s *signalWait) Signal() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
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.
ed4900b
to
28e3906
Compare
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. |
There was a problem hiding this comment.
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
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.