Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed signalctx, added NotifyContext #78

Merged
merged 4 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG VPP_VERSION=v20.09
FROM ghcr.io/edwarnicke/govpp/vpp:${VPP_VERSION} as go
COPY --from=golang:1.15.3-buster /usr/local/go/ /go
COPY --from=golang:1.16.3-buster /usr/local/go/ /go
ENV PATH ${PATH}:/go/bin
ENV GO111MODULE=on
ENV CGO_ENABLED=0
Expand Down
3 changes: 2 additions & 1 deletion internal/imports/imports_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import (
"net"
"net/url"
"os"
"os/signal"
"path/filepath"
"syscall"
"time"

nested "github.com/antonfisher/nested-logrus-formatter"
Expand Down Expand Up @@ -59,7 +61,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"
)

Expand Down Expand Up @@ -90,9 +91,8 @@ func main() {
// ********************************************************************************
// setup context to catch signals
// ********************************************************************************
ctx := signalctx.WithSignals(context.Background())
ctx, cancel := context.WithCancel(ctx)

ctx, cancel := notifyContext()
defer cancel()
// ********************************************************************************
// setup logging
// ********************************************************************************
Expand Down Expand Up @@ -281,3 +281,14 @@ func exitOnErr(ctx context.Context, cancel context.CancelFunc, errCh <-chan erro
cancel()
}(ctx, errCh)
}

func notifyContext() (context.Context, context.CancelFunc) {
return signal.NotifyContext(
context.Background(),
os.Interrupt,
// More Linux signals here
syscall.SIGHUP,
syscall.SIGTERM,
syscall.SIGQUIT,
)
}