mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +02:00
main.go: modify signal handling to also check syscall.SIGTERM
This commit is contained in:
parent
c6a2c49f9a
commit
1d6c05b402
1 changed files with 6 additions and 5 deletions
11
main.go
11
main.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
|
|
@ -103,14 +104,14 @@ func run() {
|
|||
go readerLoop()
|
||||
|
||||
// Create interrupt channel.
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signals := make(chan os.Signal, 1)
|
||||
|
||||
// Register interrupt channel to receive interrupt messages
|
||||
signal.Notify(interrupt, os.Interrupt)
|
||||
// Register signal channel to receive signals from the os.
|
||||
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
// Wait for interrupt
|
||||
<-interrupt
|
||||
log.Info("Interrupt, closing")
|
||||
sig := <-signals
|
||||
log.WithField("signal", sig).Info("Signal received")
|
||||
|
||||
if !shClient.IsOpen() {
|
||||
log.Info("ship client not connected, exiting...")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue