// GetInterruptableCtx creates a child context that gets cancelled
// if SIGTERM/SIGINT signal is caught.
GetInterruptableCtx creates a child context that gets cancelled
if SIGTERM/SIGINT signal is caught.
// GetInterruptableCtx creates a child context that gets cancelled // if SIGTERM / SIGINT signal is caught .
func GetInterruptableCtx(pctx context.Context) (cctx context.Context, cancel context.CancelFunc) {
    cctx, cancel = context.WithCancel(pctx)
    go func() {
        defer cancel()
        c := make(chan os.Signal, 1)
        signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
        select {
        case <-c:
        case <-pctx.Done():
        }
    }()
    return
}
func GetInterruptableCtx ( pctx context . Context ) ( cctx context . Context , cancel context . CancelFunc ) { cctx , cancel = context . WithCancel ( pctx ) go func ( ) { defer cancel ( ) c := make ( chan os . Signal , 1 ) signal . Notify ( c , syscall . SIGINT , syscall . SIGTERM ) select { case <- c : case <- pctx . Done ( ) : } } ( ) return }
GetInterruptableCtx creates a child context that gets cancelled
if SIGTERM/SIGINT signal is caught.
GetInterruptableCtx creates a child context that gets cancelled if SIGTERM / SIGINT signal is caught .