Skip to content

Instantly share code, notes, and snippets.

@zeusro
Last active May 11, 2021 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeusro/d4c0578e579404f9a61146860054c88a to your computer and use it in GitHub Desktop.
Save zeusro/d4c0578e579404f9a61146860054c88a to your computer and use it in GitHub Desktop.
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