fix: set timeout for run dpkg command
This commit is contained in:
@@ -701,7 +701,8 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
} else if fileType == 2 {
|
||||
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // 设置60秒超时
|
||||
timeout := time.Duration(config.GetYamlConfig().OMC.CmdTimeout) * time.Second
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout) // 设置超时
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "ssh", sshHost, dpkgCmd)
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user