go-spacemesh icon indicating copy to clipboard operation
go-spacemesh copied to clipboard

Handle SIGTERM gracefully

Open lrettig opened this issue 4 years ago • 2 comments

I noticed that sending a SIGTERM (using the kill command) causes the node to immediately exit, without even printing any message to the log. Can we trap this and handle it the same way we handle a SIGINT (ctrl-c)?

lrettig avatar Apr 25 '20 18:04 lrettig

@lrettig still relevant?

moshababo avatar Jun 26 '22 09:06 moshababo

Yes. We're gracefully handling SIGINT:

https://github.com/spacemeshos/go-spacemesh/blob/2e58ca2817765c4f7e7c2c9f7968a76d643ce285/cmd/base.go#L87-L89

but not SIGTERM (which, e.g., docker sends). This can lead to data corruption.

This is definitely doable, see: https://www.rudderstack.com/blog/implementing-graceful-shutdown-in-go/

lrettig avatar Jun 27 '22 21:06 lrettig