forked from TrueCloudLab/frostfs-http-gw
Merge pull request #47 from roman-khimov/drop-global-package
drop 'global' package
This commit is contained in:
commit
d6367f2556
2 changed files with 5 additions and 24 deletions
|
@ -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
|
||||
}
|
7
main.go
7
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()
|
||||
|
|
Loading…
Reference in a new issue