Skip to content

Commit

Permalink
Fix the panic caused by not starting LogFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
skyf0cker authored and nekohasekai committed Mar 26, 2024
1 parent 602023b commit e84282f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ func New(ctx context.Context, options option.Options) (*Server, error) {
ctx = service.ContextWithDefaultRegistry(ctx)
createdAt := time.Now()
logFactory, err := log.New(log.Options{
Context: ctx,
Options: common.PtrValueOrDefault(options.Log),
DefaultWriter: os.Stderr,
BaseTime: createdAt,
})
if err != nil {
return nil, E.Cause(err, "create log factory")
}

chiRouter := chi.NewRouter()
httpServer := &http.Server{
Addr: options.Listen,
Expand Down Expand Up @@ -128,7 +130,11 @@ func New(ctx context.Context, options option.Options) (*Server, error) {

func (s *Server) Start() error {
s.initializeRoutes()
err := s.cacheFile.Start()
err := s.logFactory.Start()
if err != nil {
return err
}
err = s.cacheFile.Start()
if err != nil {
return err
}
Expand Down

0 comments on commit e84282f

Please sign in to comment.