goreman icon indicating copy to clipboard operation
goreman copied to clipboard

Procfile configure problem

Open orainxiong opened this issue 8 years ago • 1 comments

web5: go run web.go -a :$PORT

It will cause client hang while stop web5,because of "http://stackoverflow.com/questions/24982845/process-kill-on-child-processes"

We need compile web.go to solve this problem,like below web5: go run ./web -a :$PORT

I recommend add timeout feature for function stopProc

func stopProc(proc string, quit bool) error {
    p, ok := procs[proc]
    if !ok {
        return errors.New("Unknown proc: " + proc)
    }
    p.mu.Lock()
    defer p.mu.Unlock()

    if p.cmd == nil {
        return nil
    }

    p.quit = quit
    err := terminateProc(proc)
    if err != nil {
        return err
    }

    var done = make(chan bool, 1)

    go func(done chan bool) {
        p.cond.Wait()
        done <- true
    }(done)

    select {
    case <-time.After(1 * time.Second):
        p.cond.Signal()
        <- done
        err = errors.New("stop timeout")
    case <-done:
        err = nil
    }
    return err
}

orainxiong avatar Jul 18 '16 07:07 orainxiong

goreman have implementation that send signal to process group. and have timeout already.

mattn avatar Jul 18 '16 11:07 mattn