Remove sdk context dep
Signed-off-by: Pavel Korotkov <pavel@nspcc.ru>
This commit is contained in:
parent
f77c4e49dc
commit
cdab794d62
2 changed files with 23 additions and 8 deletions
20
global/context.go
Normal file
20
global/context.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os/signal"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
globalContext context.Context
|
||||||
|
globalContexOnce sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
func Context() context.Context {
|
||||||
|
globalContexOnce.Do(func() {
|
||||||
|
globalContext, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
|
})
|
||||||
|
return globalContext
|
||||||
|
}
|
11
main.go
11
main.go
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/cdn-sdk/grace"
|
|
||||||
"github.com/nspcc-dev/cdn-sdk/logger"
|
"github.com/nspcc-dev/cdn-sdk/logger"
|
||||||
|
"github.com/nspcc-dev/neofs-http-gate/global"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -41,15 +41,10 @@ func main() {
|
||||||
var (
|
var (
|
||||||
v = settings()
|
v = settings()
|
||||||
l = newLogger(v)
|
l = newLogger(v)
|
||||||
g = grace.Context(l)
|
g = global.Context()
|
||||||
|
a = newApp(g, WithLogger(l), WithConfig(v))
|
||||||
a = newApp(g,
|
|
||||||
WithLogger(l),
|
|
||||||
WithConfig(v))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
go a.Serve(g)
|
go a.Serve(g)
|
||||||
go a.Worker(g)
|
go a.Worker(g)
|
||||||
|
|
||||||
a.Wait()
|
a.Wait()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue