diff --git a/cmd/tipgodoc/tip.go b/cmd/tipgodoc/tip.go index e60bd644a8..2dd3a7b339 100644 --- a/cmd/tipgodoc/tip.go +++ b/cmd/tipgodoc/tip.go @@ -36,7 +36,11 @@ func main() { p := new(Proxy) go p.run() http.Handle("/", p) - log.Fatal(http.ListenAndServe(":8080", nil)) + + if err := http.ListenAndServe(":8080", nil); err != nil { + p.stop() + log.Fatal(err) + } } // Proxy implements the tip.golang.org server: a reverse-proxy @@ -85,6 +89,14 @@ func (p *Proxy) run() { } } +func (p *Proxy) stop() { + p.mu.Lock() + defer p.mu.Unlock() + if p.cmd != nil { + p.cmd.Process.Kill() + } +} + // poll runs from the run loop goroutine. func (p *Proxy) poll() { heads := gerritMetaMap()