ochinchina / supervisord

a go-lang supervisor implementation
MIT License
4.03k stars 571 forks source link

滥用for循环 #356

Open pobearm opened 1 year ago

pobearm commented 1 year ago
// check if the process is running or not
func (p *Process) isRunning() bool {
    if p.cmd != nil && p.cmd.ProcessState == nil && p.cmd.Process != nil {
        if runtime.GOOS == "windows" {
            proc, err := os.FindProcess(p.cmd.Process.Pid)
            log.Info("pid: ", p.cmd.Process.Pid, " err: ", err, " porc: ", proc == nil)
            return proc != nil && err == nil
        }
        return p.cmd.Process.Signal(syscall.Signal(0)) == nil
    }
    return false
}

在这个方法中, 加一行log, 你会惊奇的发现日志刷爆了, 看了一下代码, 开了好几个goruntine + for 循环, 疯狂的调用这个方法.

yudidi commented 1 year ago

这怎么解决啊