diff --git a/features/cm/software.go b/features/cm/software.go index 485d68bb..8b9fe138 100644 --- a/features/cm/software.go +++ b/features/cm/software.go @@ -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 diff --git a/restagent/config/config.go b/restagent/config/config.go index e99724d8..81fd15f5 100644 --- a/restagent/config/config.go +++ b/restagent/config/config.go @@ -81,6 +81,7 @@ type YamlConfig struct { TestMode bool `yaml:"testMode"` RBACMode bool `yaml:"rbacMode"` RunDir string `yaml:"runDir"` + CmdTimeout int `yaml:"cmdTimeout"` } `yaml:"omc"` Alarm struct { diff --git a/restagent/etc/restconf.yaml b/restagent/etc/restconf.yaml index e4c46c8d..8f451f3d 100644 --- a/restagent/etc/restconf.yaml +++ b/restagent/etc/restconf.yaml @@ -113,6 +113,7 @@ omc: testMode: false rbacMode: true runDir: + cmdTimeout: 120 # Alarm module setting # Forward interface: