grpc / grpc-dart

The Dart language implementation of gRPC.
https://pub.dev/packages/grpc
Apache License 2.0
861 stars 271 forks source link

Add Ctrl+C Handler #512

Closed stellarpower closed 2 years ago

stellarpower commented 3 years ago

If using Unix domain sockets, the old socket needs to be cleaned up properly, or restarting the server will cause it to refuse to bind. Added a handler for SIGINT to call shutdown explicitly and then exit.

This is the first time I've written in Dart - am completely open to changes.

linux-foundation-easycla[bot] commented 3 years ago

CLA Signed

The committers are authorized under a signed CLA.

mraleph commented 3 years ago

Thanks for taking your time to contribute.

I think a better alternative is just to unlink (e.g. File.deleteSync) UDS path before trying to bind. Also you need to sign the CLA before I can look at/merge the code.

stellarpower commented 3 years ago

I agree that makes sense, but I think also gracefully cleaning up is important anyway. IMO should be encouraged as that's the general solution to the problem. I leave it up to you, I ended up abandoning the efforts in Dart and trying Go. It was interesting as a language, and the way it compiles but targets browsers is certainly fantastic, but I don't like Futures - I suppose to kill JS one has to be a bit like JS. Came to the same problem and implemented the same signal handler in Go basically. Wasn't too keen on that as a language, or protocol buffers for that matter, so wasn't Google's week!