metaverse / truss

Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.
Other
734 stars 143 forks source link

Proposal: Add a way to support gracefully shutdown #261

Closed RavenZZ closed 5 years ago

RavenZZ commented 5 years ago

In order to support to shutdown both grpc and http handler to gracefully.

Like [https://github.com/grpc/grpc-go/blob/6d55ae1afefd32ef7f6b967113b3deb48c8adc75/test/gracefulstop_test.go](grpc gracefulstop_test.go) and [https://github.com/facebookgo/grace](Facebook grace)

zaquestion commented 5 years ago

@RavenZZ In case you aren't aware in handlers/hooks.go you can access the signal handler for the service and provide graceful shutdown logic.

For example: https://github.com/zaquestion/current/blob/master/current-service/handlers/hooks.go#L10

RavenZZ commented 5 years ago

@zaquestion , I wrote my deregister(service discovery) logic in the handlers/hooks.go now. but in xxx-service/svc/server/run.go grpc server and http handler object is private. And according to the wiki https://github.com/tuneinc/truss/wiki/Levels-of-support-for-different-truss-usecases#support-level-3-not-supported-we-dont-recommend-this , edit the code in svc folder are not supported.