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 #76

Merged
merged 2 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
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/antonfisher/nested-logrus-formatter v1.3.0
github.com/edwarnicke/debug v1.0.0
github.com/edwarnicke/grpcfd v0.0.0-20210219150442-10fb469a6976
github.com/edwarnicke/signalctx v0.0.0-20201105214533-3a35840b3011
github.com/edwarnicke/vpphelper v0.0.0-20210225052320-b4f1f1aff45d
github.com/google/uuid v1.1.2
github.com/kelseyhightower/envconfig v1.4.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ github.com/edwarnicke/log v1.0.0/go.mod h1:eWsQQlQ0IU5wHlJvyXFH3dS8s2g9GzN7JnXod
github.com/edwarnicke/serialize v0.0.0-20200705214914-ebc43080eecf/go.mod h1:XvbCO/QGsl3X8RzjBMoRpkm54FIAZH5ChK2j+aox7pw=
github.com/edwarnicke/serialize v1.0.7 h1:geX8vmyu8Ij2S5fFIXjy9gBDkKxXnrMIzMoDvV0Ddac=
github.com/edwarnicke/serialize v1.0.7/go.mod h1:y79KgU2P7ALH/4j37uTSIdNavHFNttqN7pzO6Y8B2aw=
github.com/edwarnicke/signalctx v0.0.0-20201105214533-3a35840b3011 h1:rlA4xj11pzxP9w/qVP11qZkRN+7UfA8MiW6pPljW0CM=
github.com/edwarnicke/signalctx v0.0.0-20201105214533-3a35840b3011/go.mod h1:Z9/3G9n/oPyXJzsF4ucVh8YOxTlTidDLqOeWlGV1JAw=
github.com/edwarnicke/vpphelper v0.0.0-20210225052320-b4f1f1aff45d h1:Okg1uazbTBFvNTrWP5AbTLgG/xMsnZNIobxJYpyvyK8=
github.com/edwarnicke/vpphelper v0.0.0-20210225052320-b4f1f1aff45d/go.mod h1:2KXgJqOUUCh9S4Zs2jAycQLqAcRGge3q+GXV2rN55ZQ=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down
3 changes: 2 additions & 1 deletion internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
_ "github.com/antonfisher/nested-logrus-formatter"
_ "github.com/edwarnicke/debug"
_ "github.com/edwarnicke/grpcfd"
_ "github.com/edwarnicke/signalctx"
_ "github.com/edwarnicke/vpphelper"
_ "github.com/google/uuid"
_ "github.com/kelseyhightower/envconfig"
Expand All @@ -33,5 +32,7 @@ import (
_ "google.golang.org/grpc/credentials"
_ "net/url"
_ "os"
_ "os/signal"
_ "syscall"
_ "time"
)
18 changes: 15 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import (
"fmt"
"net/url"
"os"
"os/signal"
"syscall"
"time"

nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/edwarnicke/debug"
"github.com/edwarnicke/grpcfd"
"github.com/edwarnicke/signalctx"
"github.com/edwarnicke/vpphelper"
"github.com/google/uuid"
"github.com/kelseyhightower/envconfig"
Expand Down Expand Up @@ -69,8 +70,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 @@ -230,3 +231,14 @@ func exitOnErrCh(ctx context.Context, cancel context.CancelFunc, errCh <-chan er
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,
)
}