mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-06 23:35:00 +00:00
Update Go dependencies and minimal Go version to 1.20 (#1650)
Signed-off-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@@ -16,6 +16,7 @@ package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
@@ -24,7 +25,7 @@ import (
|
||||
// Returns a copy of parent context that is canceled when
|
||||
// an os interrupt signal is received.
|
||||
func WithContextSigtermCallback(ctx context.Context, f func()) context.Context {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
go func() {
|
||||
receivedSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(receivedSignal, syscall.SIGINT, syscall.SIGTERM)
|
||||
@@ -33,7 +34,7 @@ func WithContextSigtermCallback(ctx context.Context, f func()) context.Context {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-receivedSignal:
|
||||
cancel()
|
||||
cancel(fmt.Errorf("received signal: %v", receivedSignal))
|
||||
if f != nil {
|
||||
f()
|
||||
}
|
||||
|
Reference in New Issue
Block a user