Skip to content

Implement graceful shutdown #238

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

Merged
merged 2 commits into from
Dec 17, 2019
Merged

Conversation

timoreimann
Copy link
Contributor

This change implements graceful shutdown so that a proper driver termination leads to an exit code of zero.

Specifically, we handle signals, and let the HTTP and gRPC servers finish requests gracefully.

We also remove the Stop() function in favor a context-based approach.

@timoreimann timoreimann force-pushed the implement-graceful-shutdown branch from b144430 to 8a4c5f8 Compare December 11, 2019 13:55
Copy link
Contributor

@adamwg adamwg left a comment

Choose a reason for hiding this comment

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

One note on the test, but lgtm.


go func() {
err := driver.Run(ctx)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to check this error reliably, we should probably call cancel after sanity.Test returns, and use a WaitGroup or channel to wait for this goroutine to shut down before the test ends. As it's written currently, I suspect the test will be finished before this line is executed, since the defer will execute right at the end of the test function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch.

I went with an errgroup. Let me know if that makes sense to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, makes sense to me 👍

Timo Reimann added 2 commits December 18, 2019 00:01
This change implements graceful shutdown so that a proper driver
termination leads to an exit code of zero.

Specifically, we handle signals, and let the HTTP and gRPC servers
finish requests gracefully.

We also remove the Stop() function in favor a context-based approach.
@timoreimann timoreimann force-pushed the implement-graceful-shutdown branch from a541000 to e2328c1 Compare December 17, 2019 23:02
@timoreimann timoreimann merged commit 67e23ff into master Dec 17, 2019
@timoreimann timoreimann deleted the implement-graceful-shutdown branch December 17, 2019 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants