mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
refactor: Move context initialization for graceful shutdown to appropriate locations
This commit is contained in:
@@ -54,9 +54,6 @@ type Service struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (svc *Service) Start() {
|
func (svc *Service) Start() {
|
||||||
// Initialize context for graceful shutdown
|
|
||||||
svc.ctx, svc.cancel = context.WithCancel(context.Background())
|
|
||||||
|
|
||||||
// wait for grpc client ready
|
// wait for grpc client ready
|
||||||
grpcclient.GetGrpcClient().WaitForReady()
|
grpcclient.GetGrpcClient().WaitForReady()
|
||||||
|
|
||||||
@@ -376,7 +373,7 @@ func (svc *Service) updateNodeStatus() (err error) {
|
|||||||
// set available runners
|
// set available runners
|
||||||
n.CurrentRunners = svc.getRunnerCount()
|
n.CurrentRunners = svc.getRunnerCount()
|
||||||
|
|
||||||
// Log goroutine count for leak monitoring
|
// Log goroutine count for leak monitoring
|
||||||
currentGoroutines := runtime.NumGoroutine()
|
currentGoroutines := runtime.NumGoroutine()
|
||||||
svc.Debugf("Node status update - runners: %d, goroutines: %d", n.CurrentRunners, currentGoroutines)
|
svc.Debugf("Node status update - runners: %d, goroutines: %d", n.CurrentRunners, currentGoroutines)
|
||||||
|
|
||||||
@@ -510,6 +507,9 @@ func newTaskHandlerService() *Service {
|
|||||||
Logger: utils.NewLogger("TaskHandlerService"),
|
Logger: utils.NewLogger("TaskHandlerService"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize context for graceful shutdown
|
||||||
|
svc.ctx, svc.cancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
// dependency injection
|
// dependency injection
|
||||||
svc.cfgSvc = nodeconfig.GetNodeConfigService()
|
svc.cfgSvc = nodeconfig.GetNodeConfigService()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user