From 341b085d5dff7379ec98199e0d5e356e0ef6aff9 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 22 Apr 2021 09:56:32 +0700 Subject: [PATCH 1/2] removed signalctx, added NotifyContext Signed-off-by: Mikhail --- Dockerfile | 2 +- internal/imports/imports_linux.go | 3 ++- main.go | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 68e3ce69..e77bc2e7 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/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 8128bc1d..7dbffd7c 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -33,7 +33,6 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/tools/log" _ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" _ "github.com/networkservicemesh/sdk/pkg/tools/opentracing" - _ "github.com/networkservicemesh/sdk/pkg/tools/signalctx" _ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt" _ "github.com/networkservicemesh/sdk/pkg/tools/spire" _ "github.com/networkservicemesh/sdk/pkg/tools/token" @@ -52,9 +51,11 @@ import ( _ "k8s.io/kubelet/pkg/apis/podresources/v1alpha1" _ "net/url" _ "os" + _ "os/signal" _ "path" _ "path/filepath" _ "sync" + _ "syscall" _ "testing" _ "time" ) diff --git a/main.go b/main.go index 1455b388..9e1bbbff 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,8 @@ import ( "net/url" "os" "path" + "os/signal" + "syscall" "time" nested "github.com/antonfisher/nested-logrus-formatter" @@ -51,7 +53,6 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" "github.com/networkservicemesh/sdk/pkg/tools/opentracing" - "github.com/networkservicemesh/sdk/pkg/tools/signalctx" "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt" "github.com/networkservicemesh/sdk/pkg/tools/token" @@ -78,8 +79,15 @@ func main() { // ******************************************************************************** // 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 From 627323742cd4e17c42b5786f79f0316ff2b017fd Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 22 Apr 2021 10:01:21 +0700 Subject: [PATCH 2/2] formatting fix Signed-off-by: Mikhail --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 9e1bbbff..b9ba9c2a 100644 --- a/main.go +++ b/main.go @@ -23,8 +23,8 @@ import ( "io/ioutil" "net/url" "os" - "path" "os/signal" + "path" "syscall" "time"