From 8ba5a2c92ae045c6f22688cc6436b38cfe5fab3a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 25 May 2021 13:23:29 +0300 Subject: [PATCH] drop 'global' package It makes no sense as a package. Signed-off-by: Roman Khimov --- global/context.go | 22 ---------------------- main.go | 7 +++++-- 2 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 global/context.go diff --git a/global/context.go b/global/context.go deleted file mode 100644 index 8067ee8..0000000 --- a/global/context.go +++ /dev/null @@ -1,22 +0,0 @@ -package global - -import ( - "context" - "os/signal" - "sync" - "syscall" -) - -var ( - globalContext context.Context - globalContextOnce sync.Once -) - -// Context returns global context with initialized INT, TERM and HUP signal -// handlers set to notify this context. -func Context() context.Context { - globalContextOnce.Do(func() { - globalContext, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) - }) - return globalContext -} diff --git a/main.go b/main.go index 467f081..e89489b 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,10 @@ package main import ( - "github.com/nspcc-dev/neofs-http-gw/global" + "context" + "os/signal" + "syscall" + "github.com/nspcc-dev/neofs-http-gw/logger" "github.com/spf13/viper" "go.uber.org/zap" @@ -12,7 +15,7 @@ func main() { v = settings() l = newLogger(v) ) - globalContext := global.Context() + globalContext, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) app := newApp(globalContext, WithLogger(l), WithConfig(v)) go app.Serve(globalContext) app.Wait()