forked from mirror/serenity
Fix the panic caused by not starting LogFactory
This commit is contained in:
parent
06cea13da6
commit
a6d1a21560
@ -44,6 +44,7 @@ func New(ctx context.Context, options option.Options) (*Server, error) {
|
|||||||
ctx = service.ContextWithDefaultRegistry(ctx)
|
ctx = service.ContextWithDefaultRegistry(ctx)
|
||||||
createdAt := time.Now()
|
createdAt := time.Now()
|
||||||
logFactory, err := log.New(log.Options{
|
logFactory, err := log.New(log.Options{
|
||||||
|
Context: ctx,
|
||||||
Options: common.PtrValueOrDefault(options.Log),
|
Options: common.PtrValueOrDefault(options.Log),
|
||||||
DefaultWriter: os.Stderr,
|
DefaultWriter: os.Stderr,
|
||||||
BaseTime: createdAt,
|
BaseTime: createdAt,
|
||||||
@ -51,6 +52,7 @@ func New(ctx context.Context, options option.Options) (*Server, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, E.Cause(err, "create log factory")
|
return nil, E.Cause(err, "create log factory")
|
||||||
}
|
}
|
||||||
|
|
||||||
chiRouter := chi.NewRouter()
|
chiRouter := chi.NewRouter()
|
||||||
httpServer := &http.Server{
|
httpServer := &http.Server{
|
||||||
Addr: options.Listen,
|
Addr: options.Listen,
|
||||||
@ -128,7 +130,11 @@ func New(ctx context.Context, options option.Options) (*Server, error) {
|
|||||||
|
|
||||||
func (s *Server) Start() error {
|
func (s *Server) Start() error {
|
||||||
s.initializeRoutes()
|
s.initializeRoutes()
|
||||||
err := s.cacheFile.Start()
|
err := s.logFactory.Start()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = s.cacheFile.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user