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

Proposal: Graceful shutdown of generated services. #123

Closed
hasAdamr opened this issue Dec 21, 2016 · 3 comments
Closed

Proposal: Graceful shutdown of generated services. #123

hasAdamr opened this issue Dec 21, 2016 · 3 comments
Labels

Comments

@hasAdamr
Copy link
Contributor

hasAdamr commented Dec 21, 2016

When a truss service receives a shutdown signal it will drop all http connections currently in process.

It would be nice for generated services to handle shutdown gracefully

Meaning that after shutdown signal has been received:

  1. Allow no new connections
  2. Process all currently in flight connections
  3. Close any streaming connections
  4. Call cleanup functions
  5. Actually shutdown

It looks like golang 1.8 will have this built in, we could wait for that.

Or we could use an library for this functionality. We do want to make sure the library has http2 support for grpc transport.

It looks like tylerb/graceful has http2 support. I do not see any similar thing for manners after searching their repo for "http2".

Thoughts?

@zaquestion
Copy link
Member

Curious to evaluate this as it relates to #121

I'm favorable towards letting golang 1.8 own some of this.

As it currently stands truss will expose the signal handler, which is a great place to allow people to plug in x library. I think this is a good hand off of truss's ownership of the problem to the service owner.

In part because gracefully shutdown can get fairly service specific. I'm not opposed to providing a little bit out of the box, but I would like to avoid adding a dependency.

@hasAdamr
Copy link
Contributor Author

@zaquestion There currently is the issue that our server_main.go is the program that runs http.ListenAndServer and the grpc .Serve funcs. So there would be no way to add graceful restart logic as from what I can tell you would need to wrap those functions with a graceful shutdown library.

Though users do not need to use our server_main.go and perhaps if they require graceful shutdown they should create their own main package and import the generated and handler directories.

Though golang 1.8 will be released at the end of January so this issue may solve itself.

@zaquestion zaquestion changed the title Proposal: Graceful shutdown to generated services. Proposal: Graceful shutdown of generated services. Jan 20, 2017
@hasAdamr
Copy link
Contributor Author

Closing this as go 1.8 is coming out soon and will support this functionality out of the box. If someone wants something more fancy, they could add a lib to a generated service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants