frostfs-http-gw/main.go

56 lines
1.1 KiB
Go
Raw Normal View History

2019-11-06 12:33:46 +00:00
package main
2020-11-09 13:43:23 +00:00
import (
"github.com/nspcc-dev/cdn-neofs-sdk/grace"
"github.com/nspcc-dev/cdn-neofs-sdk/logger"
"github.com/spf13/viper"
"go.uber.org/zap"
)
func newLogger(v *viper.Viper) *zap.Logger {
options := []logger.Option{
logger.WithLevel(v.GetString("logger.level")),
logger.WithTraceLevel(v.GetString("logger.trace_level")),
logger.WithFormat(v.GetString("logger.format")),
logger.WithSamplingInitial(v.GetInt("logger.sampling.initial")),
logger.WithSamplingThereafter(v.GetInt("logger.sampling.thereafter")),
logger.WithAppName(v.GetString("app_name")),
logger.WithAppVersion(v.GetString("app_version")),
}
if v.GetBool("logger.no_caller") {
options = append(options, logger.WithoutCaller())
}
if v.GetBool("logger.no_disclaimer") {
options = append(options, logger.WithoutDisclaimer())
}
l, err := logger.New(options...)
if err != nil {
panic(err)
}
return l
}
2019-11-06 12:33:46 +00:00
func main() {
var (
v = settings()
l = newLogger(v)
2020-11-09 13:43:23 +00:00
g = grace.Context(l)
2020-11-09 13:43:23 +00:00
a = newApp(g,
2020-03-31 08:37:10 +00:00
WithLogger(l),
WithConfig(v))
)
2019-11-06 12:33:46 +00:00
2020-03-31 08:37:10 +00:00
go a.Serve(g)
go a.Worker(g)
2020-03-31 08:37:10 +00:00
a.Wait()
2019-11-06 12:33:46 +00:00
}