refactor: improve mongo client connection error logging format and remove redundant gRPC server start in MasterService

This commit is contained in:
Marvin Zhang
2025-07-09 14:06:10 +08:00
parent 46c0cd6298
commit 20ba390cf6
3 changed files with 441 additions and 260 deletions

View File

@@ -2,6 +2,9 @@ package service
import (
"errors"
"sync"
"time"
"github.com/apex/log"
"github.com/cenkalti/backoff/v4"
"github.com/crawlab-team/crawlab/core/constants"
@@ -21,8 +24,6 @@ import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
mongo2 "go.mongodb.org/mongo-driver/mongo"
"sync"
"time"
)
type MasterService struct {
@@ -42,10 +43,8 @@ type MasterService struct {
}
func (svc *MasterService) Start() {
// start grpc server
if err := svc.server.Start(); err != nil {
panic(err)
}
// gRPC server is now started earlier in main.go to avoid race conditions
// No need to start it here anymore
// register to db
if err := svc.Register(); err != nil {