Merge pull request #47 from roman-khimov/drop-global-package

drop 'global' package
This commit is contained in:
masterSplinter01 2021-05-25 15:30:31 +03:00 committed by GitHub
commit d6367f2556
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 24 deletions

View file

@ -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
}

View file

@ -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()