From dfb7f1e9ec2a2f394dbc614ab2f9c2f499007d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E8=8F=B2?= Date: Thu, 19 Aug 2021 18:19:25 +0800 Subject: [PATCH 1/2] fix: adjust dfget download log (#564) * fix: adjust dfget download log Signed-off-by: zuozheng.hzz --- client/dfget/dfget.go | 8 ++++---- cmd/dfget/cmd/root.go | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/dfget/dfget.go b/client/dfget/dfget.go index 01fd112ae4d..8c9df1c220a 100644 --- a/client/dfget/dfget.go +++ b/client/dfget/dfget.go @@ -107,8 +107,8 @@ func download(ctx context.Context, client daemonclient.DaemonClient, cfg *config _ = pb.Close() } - wLog.Infof("download from daemon success, length: %dByte cost: %dms", result.CompletedLength, time.Now().Sub(start).Milliseconds()) - fmt.Printf("finish total length %d Byte\n", result.CompletedLength) + wLog.Infof("download from daemon success, length: %d bytes cost: %d ms", result.CompletedLength, time.Now().Sub(start).Milliseconds()) + fmt.Printf("finish total length %d bytes\n", result.CompletedLength) break } @@ -174,8 +174,8 @@ func downloadFromSource(ctx context.Context, cfg *config.DfgetConfig, hdr map[st return err } - wLog.Infof("download from source success, length: %dByte cost: %dms", written, time.Now().Sub(start).Milliseconds()) - fmt.Printf("finish total length %d Byte\n", written) + wLog.Infof("download from source success, length: %d bytes cost: %d ms", written, time.Now().Sub(start).Milliseconds()) + fmt.Printf("finish total length %d bytes\n", written) return nil } diff --git a/cmd/dfget/cmd/root.go b/cmd/dfget/cmd/root.go index 3e96304b91e..cfaee67c959 100644 --- a/cmd/dfget/cmd/root.go +++ b/cmd/dfget/cmd/root.go @@ -82,17 +82,22 @@ var rootCmd = &cobra.Command{ } fmt.Printf("--%s-- %s\n", start.Format("2006-01-02 15:04:05"), dfgetConfig.URL) - fmt.Printf("current user[%s] output path[%s]\n", basic.Username, dfgetConfig.Output) - fmt.Printf("dfget version[%s] default peer ip[%s]\n", version.GitVersion, iputils.HostIP) + fmt.Printf("dfget version: %s\n", version.GitVersion) + fmt.Printf("current user: %s, default peer ip: %s\n", basic.Username, iputils.HostIP) + fmt.Printf("output path: %s\n", dfgetConfig.Output) // do get file + var errInfo string err := runDfget() + if err != nil { + errInfo = fmt.Sprintf("error: %v", err) + } - msg := fmt.Sprintf("download success: %t cost: %dms error:[%v]", err == nil, time.Now().Sub(start).Milliseconds(), err) + msg := fmt.Sprintf("download success: %t cost: %d ms %s", err == nil, time.Now().Sub(start).Milliseconds(), errInfo) logger.With("url", dfgetConfig.URL).Info(msg) fmt.Println(msg) - return errors.Wrapf(err, "download url[%s]", dfgetConfig.URL) + return errors.Wrapf(err, "download url: %s", dfgetConfig.URL) }, } From f73fc50335009a0ebce15bd583ebb01ce2ec7611 Mon Sep 17 00:00:00 2001 From: Gaius Date: Thu, 19 Aug 2021 19:26:52 +0800 Subject: [PATCH 2/2] 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() }