mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-04 12:03:41 +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"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
|
|
@ -103,14 +104,14 @@ func run() {
|
||||||
go readerLoop()
|
go readerLoop()
|
||||||
|
|
||||||
// Create interrupt channel.
|
// Create interrupt channel.
|
||||||
interrupt := make(chan os.Signal, 1)
|
signals := make(chan os.Signal, 1)
|
||||||
|
|
||||||
// Register interrupt channel to receive interrupt messages
|
// Register signal channel to receive signals from the os.
|
||||||
signal.Notify(interrupt, os.Interrupt)
|
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
// Wait for interrupt
|
// Wait for interrupt
|
||||||
<-interrupt
|
sig := <-signals
|
||||||
log.Info("Interrupt, closing")
|
log.WithField("signal", sig).Info("Signal received")
|
||||||
|
|
||||||
if !shClient.IsOpen() {
|
if !shClient.IsOpen() {
|
||||||
log.Info("ship client not connected, exiting...")
|
log.Info("ship client not connected, exiting...")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue