From e9c987c925687b69083efa25a769536713910221 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 22 Apr 2021 09:43:04 +0700 Subject: [PATCH 1/2] removed signalctx, added NotifyContext Signed-off-by: Mikhail --- Dockerfile | 2 +- main.go | 12 +++++++++++- pkg/internal/imports/imports.go | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a2ba173..5698e32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.15-buster as go +FROM golang:1.16-buster as go ENV GO111MODULE=on ENV CGO_ENABLED=0 ENV GOBIN=/bin diff --git a/main.go b/main.go index fc97be2..4569ad1 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,8 @@ import ( "context" "net/url" "os" + "os/signal" + "syscall" "time" "github.com/networkservicemesh/sdk-k8s/pkg/registry/chains/registryk8s" @@ -52,7 +54,15 @@ func main() { var config = new(Config) // Setup context to catch signals ctx := signalctx.WithSignals(context.Background()) - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := signal.NotifyContext( + context.Background(), + os.Interrupt, + // More Linux signals here + syscall.SIGHUP, + syscall.SIGTERM, + syscall.SIGQUIT, + ) + defer cancel() // Setup logging logrus.SetFormatter(&nested.Formatter{}) diff --git a/pkg/internal/imports/imports.go b/pkg/internal/imports/imports.go index 3a1b43c..8746b5f 100644 --- a/pkg/internal/imports/imports.go +++ b/pkg/internal/imports/imports.go @@ -21,5 +21,7 @@ import ( _ "google.golang.org/grpc/credentials" _ "net/url" _ "os" + _ "os/signal" + _ "syscall" _ "time" ) From 2d1514d51b2f076e252fa4deba8e89cf2bc35480 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 22 Apr 2021 09:49:34 +0700 Subject: [PATCH 2/2] removed unused code Signed-off-by: Mikhail --- main.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/main.go b/main.go index 4569ad1..a733b45 100644 --- a/main.go +++ b/main.go @@ -41,7 +41,6 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/grpcutils" "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" - "github.com/networkservicemesh/sdk/pkg/tools/signalctx" ) // Config is configuration for cmd-registry-memory @@ -53,7 +52,6 @@ type Config struct { func main() { var config = new(Config) // Setup context to catch signals - ctx := signalctx.WithSignals(context.Background()) ctx, cancel := signal.NotifyContext( context.Background(), os.Interrupt,