Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
This commit is contained in:
Josh Soref
2022-11-09 02:12:17 -05:00
committed by GitHub
parent bb99d5cb6d
commit 023d03dd61
49 changed files with 76 additions and 76 deletions

View File

@@ -26,13 +26,13 @@ import (
func WithContextSigtermCallback(ctx context.Context, f func()) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
recivedSignal := make(chan os.Signal, 1)
signal.Notify(recivedSignal, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(recivedSignal)
receivedSignal := make(chan os.Signal, 1)
signal.Notify(receivedSignal, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(receivedSignal)
select {
case <-ctx.Done():
case <-recivedSignal:
case <-receivedSignal:
cancel()
if f != nil {
f()