Skip to content

Commit 4a2ae07

Browse files
committed
Update the signal type pbench handles
It should be SIGTERM, SIGINT, and SIGQUIT
1 parent f21bf29 commit 4a2ae07

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

cmd/loadjson/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"pbench/utils"
1616
"reflect"
1717
"sync"
18+
"syscall"
1819
"time"
1920
)
2021

@@ -60,8 +61,8 @@ func Run(_ *cobra.Command, args []string) {
6061
log.Info().Int("parallelism", Parallelism).Send()
6162
ctx, cancel := context.WithCancel(context.Background())
6263
timeToExit := make(chan os.Signal, 1)
63-
signal.Notify(timeToExit, os.Interrupt, os.Kill)
64-
// Handle SIGKILL and SIGINT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
64+
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
65+
// Handle SIGINT, SIGTERM, and SIGQUIT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
6566
go func() {
6667
sig := <-timeToExit
6768
if sig != nil {

cmd/replay/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"pbench/presto"
1414
"pbench/utils"
1515
"sync"
16+
"syscall"
1617
"time"
1718
)
1819

@@ -43,8 +44,8 @@ func Run(_ *cobra.Command, args []string) {
4344

4445
ctx, cancel := context.WithCancel(context.Background())
4546
timeToExit := make(chan os.Signal, 1)
46-
signal.Notify(timeToExit, os.Interrupt, os.Kill)
47-
// Handle SIGKILL and SIGINT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
47+
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
48+
// Handle SIGINT, SIGTERM, and SIGQUIT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
4849
go func() {
4950
sig := <-timeToExit
5051
if sig != nil {

cmd/save/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"pbench/utils"
1616
"strings"
1717
"sync"
18+
"syscall"
1819
"time"
1920
)
2021

@@ -46,8 +47,8 @@ func Run(_ *cobra.Command, args []string) {
4647
log.Info().Int("parallelism", Parallelism).Send()
4748
ctx, cancel := context.WithCancel(context.Background())
4849
timeToExit := make(chan os.Signal, 1)
49-
signal.Notify(timeToExit, os.Interrupt, os.Kill)
50-
// Handle SIGKILL and SIGINT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
50+
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
51+
// Handle SIGINT, SIGTERM, and SIGQUIT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
5152
go func() {
5253
sig := <-timeToExit
5354
if sig != nil {

stage/stage.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"strconv"
2121
"sync"
2222
"sync/atomic"
23+
"syscall"
2324
"time"
2425

2526
"github.com/rs/zerolog"
@@ -131,7 +132,7 @@ func (s *Stage) Run(ctx context.Context) int {
131132
results := make([]*QueryResult, 0, len(s.Queries)+len(s.QueryFiles))
132133
s.States.resultChan = make(chan *QueryResult, 16)
133134
timeToExit := make(chan os.Signal, 1)
134-
signal.Notify(timeToExit, os.Interrupt, os.Kill)
135+
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
135136
// Each goroutine we spawn will increment this wait group (count-down latch). We may start a goroutine for running
136137
// a benchmark stage, or write query output to disk asynchronously.
137138
// This wait group is propagated to the descendant stages.

0 commit comments

Comments
 (0)