Last active
May 11, 2021 06:04
-
-
Save zeusro/d4c0578e579404f9a61146860054c88a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signalChan := make(chan os.Signal) | |
// When using 'docker stop' to stop Container,'docker stop' will send SIGTERM to Container main process | |
// After 10 seconds,if container is still alive,Docker Damon will send SIGKILL to Kill Container | |
signal.Notify(signalChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) | |
go func() { | |
// do what you want | |
}() | |
<-signalChan | |
signalChan <- syscall.SIGINT | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment