Skip to content

Commit 41b1bd6

Browse files
fix: handle SIGTERM / SIGINT
1 parent f0ba4a4 commit 41b1bd6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/semantic-release/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"io/ioutil"
77
"log"
88
"os"
9+
"os/signal"
910
"strings"
11+
"syscall"
1012

1113
"github.com/Masterminds/semver/v3"
1214
"github.com/go-semantic-release/semantic-release/v2/pkg/config"
@@ -75,6 +77,13 @@ func cliHandler(cmd *cobra.Command, args []string) {
7577
pluginManager.Stop()
7678
}
7779

80+
c := make(chan os.Signal)
81+
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
82+
go func() {
83+
<-c
84+
exitIfError(errors.New("terminating..."))
85+
}()
86+
7887
ci, err := pluginManager.GetCICondition()
7988
exitIfError(err)
8089
logger.Printf("ci-condition plugin: %s@%s\n", ci.Name(), ci.Version())

0 commit comments

Comments
 (0)