cmd/tipgodoc: enable indexing
Run godoc indexing just once on startup. Wait for indexing to complete before switching to new side. Increase startup timeout to accommodate for indexing. Updates golang/go#9996. Change-Id: I1e746a68b7d787e6d7f180c2617ea75f0d3291f8 Reviewed-on: https://go-review.googlesource.com/7120 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
92211c448d
commit
a160d803d7
|
@ -1,4 +1,4 @@
|
||||||
FROM golang:1.4.1
|
FROM golang:1.4.2
|
||||||
|
|
||||||
RUN apt-get update && apt-get install --no-install-recommends -y -q build-essential git
|
RUN apt-get update && apt-get install --no-install-recommends -y -q build-essential git
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -28,6 +29,8 @@ const (
|
||||||
metaURL = "https://go.googlesource.com/?b=master&format=JSON"
|
metaURL = "https://go.googlesource.com/?b=master&format=JSON"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var indexingMsg = []byte("Indexing in progress: result may be inaccurate")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
p := new(Proxy)
|
p := new(Proxy)
|
||||||
go p.run()
|
go p.run()
|
||||||
|
@ -165,7 +168,7 @@ func initSide(side, goHash, toolsHash string) (godoc *exec.Cmd, hostport string,
|
||||||
if side == "b" {
|
if side == "b" {
|
||||||
hostport = "localhost:8082"
|
hostport = "localhost:8082"
|
||||||
}
|
}
|
||||||
godoc = exec.Command(godocBin, "-http="+hostport)
|
godoc = exec.Command(godocBin, "-http="+hostport, "-index", "-index_interval=-1s")
|
||||||
godoc.Env = []string{"GOROOT=" + goDir}
|
godoc.Env = []string{"GOROOT=" + goDir}
|
||||||
// TODO(adg): log this somewhere useful
|
// TODO(adg): log this somewhere useful
|
||||||
godoc.Stdout = os.Stdout
|
godoc.Stdout = os.Stdout
|
||||||
|
@ -180,18 +183,21 @@ func initSide(side, goHash, toolsHash string) (godoc *exec.Cmd, hostport string,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for i := 0; i < 15; i++ {
|
for i := 0; i < 120; i++ {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
var res *http.Response
|
var res *http.Response
|
||||||
res, err = http.Get(fmt.Sprintf("http://%v/", hostport))
|
res, err = http.Get(fmt.Sprintf("http://%v/search?q=FALLTHROUGH", hostport))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
rbody, err := ioutil.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if res.StatusCode == http.StatusOK {
|
if err == nil && res.StatusCode == http.StatusOK &&
|
||||||
|
!bytes.Contains(rbody, indexingMsg) {
|
||||||
return godoc, hostport, nil
|
return godoc, hostport, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
godoc.Process.Kill()
|
||||||
return nil, "", fmt.Errorf("timed out waiting for side %v at %v (%v)", side, hostport, err)
|
return nil, "", fmt.Errorf("timed out waiting for side %v at %v (%v)", side, hostport, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue