cmd: drop grace package dependency

Note that signal.NotifyContext is a Go 1.16 feature.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2021-05-25 13:30:54 +03:00
parent 787c6836aa
commit 69e3e22dbc
3 changed files with 18 additions and 11 deletions

View file

@ -6,12 +6,13 @@ import (
"encoding/json"
"fmt"
"os"
"os/signal"
"syscall"
"time"
sdk "github.com/nspcc-dev/cdn-sdk"
"github.com/nspcc-dev/cdn-sdk/creds/hcs"
"github.com/nspcc-dev/cdn-sdk/creds/neofs"
"github.com/nspcc-dev/cdn-sdk/grace"
"github.com/nspcc-dev/cdn-sdk/pool"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
"github.com/nspcc-dev/neofs-s3-gw/authmate"
@ -66,10 +67,11 @@ func prepare() (context.Context, *zap.Logger) {
var (
err error
log = zap.NewNop()
ctx, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
)
if !logEnabledFlag {
return grace.Context(log), log
return ctx, log
} else if logDebugEnabledFlag {
zapConfig.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
}
@ -78,7 +80,7 @@ func prepare() (context.Context, *zap.Logger) {
panic(err)
}
return grace.Context(log), log
return ctx, log
}
func main() {

View file

@ -1,7 +1,10 @@
package main
import (
"github.com/nspcc-dev/cdn-sdk/grace"
"context"
"os/signal"
"syscall"
"github.com/nspcc-dev/cdn-sdk/logger"
"github.com/spf13/viper"
"go.uber.org/zap"
@ -41,7 +44,7 @@ func main() {
var (
v = newSettings()
l = newLogger(v)
g = grace.Context(l)
g, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
a = newApp(g, l, v)
)

4
go.mod
View file

@ -1,6 +1,6 @@
module github.com/nspcc-dev/neofs-s3-gw
go 1.14
go 1.16
require (
github.com/aws/aws-sdk-go v1.37.9
@ -8,6 +8,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/nspcc-dev/cdn-sdk v0.3.4
github.com/nspcc-dev/neofs-api-go v1.23.0
github.com/nspcc-dev/neofs-crypto v0.3.0
github.com/nspcc-dev/neofs-node v1.22.0
github.com/prometheus/client_golang v1.9.0
github.com/spf13/pflag v1.0.5
@ -15,5 +16,6 @@ require (
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
google.golang.org/grpc v1.35.0
)