-
-
Save LinkTsang/e3a51f31549dde07d3d39926c7b3bbcb to your computer and use it in GitHub Desktop.
Revisions
-
matejb created this gist
May 20, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ func contextWithSigterm(ctx context.Context) context.Context { ctxWithCancel, cancel := context.WithCancel(ctx) go func() { defer cancel() signalCh := make(chan os.Signal, 1) signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM) select { case <-signalCh: case <-ctx.Done(): } }() return ctxWithCancel }