Add SIGKILL to shutdown signals (#1552)
* Add SIGKILL to shutdown signals * go mod tidy * Add missing file
This commit is contained in:
parent
7c31edd5f8
commit
e5c215556e
@ -5,13 +5,13 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/micro/go-micro/v2/codec"
|
||||
"github.com/micro/go-micro/v2/logger"
|
||||
"github.com/micro/go-micro/v2/registry"
|
||||
signalutil "github.com/micro/go-micro/v2/util/signal"
|
||||
)
|
||||
|
||||
// Server is a simple micro server abstraction
|
||||
@ -200,7 +200,7 @@ func Run() error {
|
||||
}
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT)
|
||||
signal.Notify(ch, signalutil.ShutdownSignals()...)
|
||||
if logger.V(logger.InfoLevel, log) {
|
||||
log.Infof("Received signal %s", <-ch)
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/micro/go-micro/v2/auth"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
@ -18,6 +17,7 @@ import (
|
||||
"github.com/micro/go-micro/v2/plugin"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v2/store"
|
||||
signalutil "github.com/micro/go-micro/v2/util/signal"
|
||||
"github.com/micro/go-micro/v2/util/wrapper"
|
||||
)
|
||||
|
||||
@ -210,7 +210,7 @@ func (s *service) Run() error {
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
if s.opts.Signal {
|
||||
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
signal.Notify(ch, signalutil.ShutdownSignals()...)
|
||||
}
|
||||
|
||||
select {
|
||||
|
13
util/signal/signal.go
Normal file
13
util/signal/signal.go
Normal file
@ -0,0 +1,13 @@
|
||||
package signal
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// ShutDownSingals returns all the singals that are being watched for to shut down services.
|
||||
func ShutdownSignals() []os.Signal {
|
||||
return []os.Signal{
|
||||
syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL,
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
@ -20,6 +19,7 @@ import (
|
||||
maddr "github.com/micro/go-micro/v2/util/addr"
|
||||
mhttp "github.com/micro/go-micro/v2/util/http"
|
||||
mnet "github.com/micro/go-micro/v2/util/net"
|
||||
signalutil "github.com/micro/go-micro/v2/util/signal"
|
||||
mls "github.com/micro/go-micro/v2/util/tls"
|
||||
)
|
||||
|
||||
@ -404,7 +404,7 @@ func (s *service) Run() error {
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
if s.opts.Signal {
|
||||
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT)
|
||||
signal.Notify(ch, signalutil.ShutdownSignals()...)
|
||||
}
|
||||
|
||||
select {
|
||||
|
Loading…
x
Reference in New Issue
Block a user