From f73fc50335009a0ebce15bd583ebb01ce2ec7611 Mon Sep 17 00:00:00 2001 From: Gaius Date: Thu, 19 Aug 2021 19:26:52 +0800 Subject: [PATCH] feat: empty scheduler job (#565) * feat: empty scheduler job Signed-off-by: Gaius --- scheduler/scheduler.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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() }