Skip to content

Commit

Permalink
Merge pull request #15 from geniussportsgroup/develop
Browse files Browse the repository at this point in the history
New handler with a continuation function
  • Loading branch information
lrleon authored Apr 16, 2021
2 parents a229666 + bb0043f commit cd0f294
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions simple_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,7 @@ func SetNumberOfPods(numPods int32, currentNumOfPods *int32,
// TerminationHandler goroutine for handling SIGTERM
func TerminationHandler(timeout time.Duration) {

log.Printf("Setting termination handler for process pid = %d", os.Getpid())
signChannel := make(chan os.Signal, 1)

signal.Ignore(syscall.SIGINT, syscall.SIGQUIT, syscall.SIGCONT)
signal.Notify(signChannel, syscall.SIGTERM)

sig := <-signChannel

log.Printf("Termination received (%s)", sig.String())

time.Sleep(timeout)

os.Exit(0)
TerminationHandlerCont(timeout, nil)
}

// TerminationHandlerCont set a termination handler. When SIGTERM is received, waits for timeout. Next
Expand All @@ -214,12 +202,12 @@ func TerminationHandlerCont(timeout time.Duration, continuation func(pars ...int

log.Printf("Termination received (%s)", sig.String())

time.Sleep(timeout)

if continuation != nil {
continuation(pars...)
}

time.Sleep(timeout)

os.Exit(0)
}

Expand Down

0 comments on commit cd0f294

Please sign in to comment.