77 "os"
88 "os/signal"
99 "path/filepath"
10+ "strings"
1011 "syscall"
1112 "time"
1213
@@ -15,10 +16,11 @@ import (
1516 "golang.org/x/exp/slog"
1617 "google.golang.org/grpc/grpclog"
1718
19+ "github.com/easyp-tech/server/internal/logger"
20+
1821 "github.com/easyp-tech/server/internal/api"
1922 "github.com/easyp-tech/server/internal/core"
2023 "github.com/easyp-tech/server/internal/grpchelper"
21- "github.com/easyp-tech/server/internal/logkey"
2224 "github.com/easyp-tech/server/internal/metrics"
2325 "github.com/easyp-tech/server/internal/serve"
2426 "github.com/easyp-tech/server/internal/store"
@@ -27,9 +29,8 @@ import (
2729type (
2830 //nolint:tagliatelle
2931 config struct {
30- DevMode bool `json:"dev_mode"`
31- Server server `json:"server"`
32- Store storage `json:"storage"`
32+ Server server `json:"server"`
33+ Store storage `json:"storage"`
3334 }
3435 server struct {
3536 External external `json:"external"`
4445 Port ports `json:"port"`
4546 }
4647 storage struct {
47- Root string `json:"root"`
48- URLS []string `json:"urls"`
48+ Root string `json:"root"`
4949 }
5050)
5151
@@ -60,9 +60,9 @@ func main() {
6060
6161 grpclog .SetLoggerV2 (grpchelper .NewLogger (log ))
6262
63- appName := filepath .Base (os .Args [0 ])
63+ appName := strings . Replace ( filepath .Base (os .Args [0 ]), "-" , "_" , - 1 )
6464
65- ctxParent := logkey .NewContext (context .Background (), log )
65+ ctxParent := logger .NewContext (context .Background (), log )
6666
6767 ctx , cancel := signal .NotifyContext (
6868 ctxParent ,
@@ -77,34 +77,30 @@ func main() {
7777 go forceShutdown (ctx )
7878
7979 if err := start (ctx , cfg , appName ); err != nil {
80- log .Error ("shutdown" , slog .String (logkey .Error , err .Error ()))
80+ log .Error ("shutdown" , slog .String (logger .Error , err .Error ()))
8181 os .Exit (1 )
8282 }
8383}
8484
8585func start (ctx context.Context , cfg config , namespace string ) error {
86- log := logkey .FromContext (ctx )
86+ log := logger .FromContext (ctx )
8787 reg := prometheus .NewPedanticRegistry ()
8888 m := metrics .New (reg , namespace )
8989
90- s , err := store .New (ctx , cfg .Store .Root , cfg .Store .URLS )
91- if err != nil {
92- return fmt .Errorf ("store.New: %w" , err )
93- }
94-
90+ s := store .New (ctx , cfg .Store .Root )
9591 module := core .New (s )
9692 _ , httpAPI := api .New (ctx , m , module , reg , namespace , cfg .Server .External .Domain )
9793
9894 return serve .Start ( //nolint:wrapcheck
9995 ctx ,
10096 serve .Metrics (
101- log .With (slog .String (logkey .Module , "metric" )),
97+ log .With (slog .String (logger .Module , "metric" )),
10298 cfg .Server .External .Host ,
10399 cfg .Server .External .Port .Metric ,
104100 reg ,
105101 ),
106102 serve .HTTP (
107- log .With (slog .String (logkey .Module , "gRPC-Gateway " )),
103+ log .With (slog .String (logger .Module , "connect " )),
108104 cfg .Server .External .Host ,
109105 cfg .Server .External .Port .Connect ,
110106 httpAPI ,
@@ -113,7 +109,7 @@ func start(ctx context.Context, cfg config, namespace string) error {
113109}
114110
115111func forceShutdown (ctx context.Context ) {
116- log := logkey .FromContext (ctx )
112+ log := logger .FromContext (ctx )
117113
118114 const shutdownDelay = 15 * time .Second
119115
0 commit comments