// IsKubeEdgeProcessRunning checks if the given process is running or not funcIsKubeEdgeProcessRunning(proc string) (bool, error) { //pidof是Linux系统中用来查找正在运行进程的进程号(pid)的工具 // proc=cloudcore procRunning := fmt.Sprintf("pidof %s 2>&1", proc) cmd := NewCommand(procRunning)
cfg := &action.Configuration{} // let the os.Stdout not print the details logFunc := func(format string, v ...interface{}) {} if err := cfg.Init(cf, cu.Namespace, "", logFunc); err != nil { returnnil, err }
// a flag to confirm the install/upgrade action var performInstall bool _, err := cfg.Releases.Last(r.componentName) if err != nil && errors.Is(err, driver.ErrReleaseNotFound) { performInstall = true }
if performInstall { helmInstall := action.NewInstall(cfg) helmInstall.DryRun = cu.DryRun helmInstall.Namespace = cu.Namespace // --force would not wait. if !cu.Force { helmInstall.Wait = DefaultHelmWait helmInstall.Timeout = DefaultHelmTimeout } helmInstall.CreateNamespace = DefaultHelmCreateNs helmInstall.ReleaseName = r.componentName
// try to update a version helmUpgrade := action.NewUpgrade(cfg) helmUpgrade.DryRun = cu.DryRun helmUpgrade.Namespace = cu.Namespace // --force would not wait. if !cu.Force { helmUpgrade.Wait = DefaultHelmWait helmUpgrade.Timeout = DefaultHelmTimeout }