From e0f0035a7d02098f14e9d800a16d42d4c9380e9c Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期五, 20 十二月 2019 16:22:25 +0800 Subject: [PATCH] test --- service/SysService.go | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/service/SysService.go b/service/SysService.go index b2acfb7..4b14658 100644 --- a/service/SysService.go +++ b/service/SysService.go @@ -124,7 +124,7 @@ } defer file.Close() writer := bufio.NewWriter(file) - chunkData := make([]byte, arg.Header.Size) + chunkData := make([]byte, arg.CurrentChunkSize) n, err := (*arg.File).ReadAt(chunkData, 0) if n ==0 || err !=nil { logger.Debug("read chunkData err:",err,"n:",n) @@ -208,9 +208,9 @@ if !util.CreateDirectory(configBakPath) { return false } - b, err := ExecCmd("cp /opt/vasystem/bin /opt/vasystem/bak") - logger.Debug("bakBeforeUpgrade result:",string(b)) + b, err := ExecCmd("cp -r /opt/vasystem/bin /opt/vasystem/bak") if err != nil { + logger.Debug("bakBeforeUpgrade result:",string(b),"err:",err) return false } return true @@ -243,20 +243,29 @@ logger.Debug("UnZip err:",err,"zipFile:",zipFilePath) return false } + + //濡傛灉閫氱敤鑴氭湰鏈夋洿鏂帮紝鍒欐洿鏂伴�氱敤鑴氭湰 + if util.Exists(unZipPath+"updatePatch.sh") { + cpStr := fmt.Sprintf("cp %s /opt/vasystem/bin",unZipPath+"updatePatch.sh") + b, err := ExecCmd(cpStr) + if err != nil { + logger.Debug("cp updatePatch.sh to bin err:",err,"result:",string(b)) + return false + } + } + //鍒ゆ柇鏇存柊鍖呴噷鏄惁鏈夎ˉ涓佽剼鏈紝濡傛灉鏈夊垯鎵ц锛屽惁鍒欐墽琛寀pdatePatch.sh updateCmd := fmt.Sprintf("./updatePatch.sh %s %s %s &",unZipPath,zipFilePath,configPatchPath+"/"+identifier) if util.Exists(unZipPath+"upgrade.sh") { updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s &",unZipPath,unZipPath,zipFilePath,configPatchPath+"/"+identifier) - logger.Debug("upgrade use ",unZipPath,"upgrade.sh") } //2.鏇存柊绯荤粺 - var cmd *exec.Cmd - cmd = exec.Command("/bin/sh","-c", updateCmd) - if b, err := cmd.Output(); err != nil { - logger.Debug("updatePatch err:",err,"result:",string(b)) + b,err := ExecCmd(updateCmd) + if err != nil { + logger.Debug("upgrade err:",err,"result:",string(b),"cmd:",updateCmd) return false } else { - logger.Debug("updatePatch result:",string(b),"cmd:",updateCmd) + logger.Debug("upgrade result:",string(b),"cmd:",updateCmd) } return true } -- Gitblit v1.8.0