diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 2891798106f..3c6c648e48a 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -134,12 +134,14 @@ func (s *Server) Serve() error { }() // Serve Job - go func() { - if err := s.job.Serve(); err != nil { - logger.Fatalf("job start failed %v", err) - } - logger.Info("job start successfully") - }() + if s.job != nil { + go func() { + if err := s.job.Serve(); err != nil { + logger.Fatalf("job start failed %v", err) + } + logger.Info("job start successfully") + }() + } // Serve Keepalive if s.managerClient != nil { @@ -226,9 +228,13 @@ func (s *Server) keepAlive(ctx context.Context) error { } func (s *Server) Stop() { - s.managerConn.Close() + if s.managerConn != nil { + s.managerConn.Close() + } s.dynConfig.Stop() s.schedulerService.Stop() - s.job.Stop() + if s.job != nil { + s.job.Stop() + } rpc.StopServer() }