cmd/golangorg: serve tip.golang.org directly from Gerrit
This CL enables the code, committed in an earlier CL, that serves tip.golang.org from an in-memory copy of the Go repo, updated by a background loop, which will let us retire the more heavyweight "deploy a whole new app in a loop" that we currently use for tip.golang.org. When this CL is committed, the "deploy a whole new app in a loop" logic will deploy this new code, which will then start using the in-memory copy, even though it is also being updated on each change. At that point it will be safe to take down the app-updating loop entirely, letting the default app do the serving. Change-Id: Ica5cffd684c45d4a5b059772700a0a608f832bad Reviewed-on: https://go-review.googlesource.com/c/website/+/335049 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Website-Publish: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Родитель
f4281e3dec
Коммит
42b41e29af
|
@ -113,6 +113,8 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isTestBinary = false
|
||||||
|
|
||||||
// NewHandler returns the http.Handler for the web site,
|
// NewHandler returns the http.Handler for the web site,
|
||||||
// given the directory where the content can be found
|
// given the directory where the content can be found
|
||||||
// (can be "", in which case an internal copy is used)
|
// (can be "", in which case an internal copy is used)
|
||||||
|
@ -144,25 +146,20 @@ func NewHandler(contentDir, goroot string) http.Handler {
|
||||||
log.Fatalf("newSite: %v", err)
|
log.Fatalf("newSite: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we are ready to start serving tip.golang.org
|
// tip.golang.org serves content from the very latest Git commit
|
||||||
// from the default golang-org app instead of a separate app,
|
// of the main Go repo, instead of the one the app is bundled with.
|
||||||
// we can set serveTip = true.
|
var tipGoroot atomicFS
|
||||||
const serveTip = false
|
if _, err := newSite(mux, "tip.golang.org", content, &tipGoroot); err != nil {
|
||||||
|
log.Fatalf("loading tip site: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
if serveTip {
|
// TODO(rsc): Replace with redirect to tip
|
||||||
// tip.golang.org serves content from the very latest Git commit
|
// once tip is being served by this app.
|
||||||
// of the main Go repo, instead of the one the app is bundled with.
|
if _, err := newSite(mux, "beta.golang.org", content, &tipGoroot); err != nil {
|
||||||
var tipGoroot atomicFS
|
log.Fatalf("loading beta site: %v", err)
|
||||||
if _, err := newSite(mux, "tip.golang.org", content, &tipGoroot); err != nil {
|
}
|
||||||
log.Fatalf("loading tip site: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(rsc): Replace with redirect to tip
|
|
||||||
// once tip is being served by this app.
|
|
||||||
if _, err := newSite(mux, "beta.golang.org", content, &tipGoroot); err != nil {
|
|
||||||
log.Fatalf("loading beta site: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if !isTestBinary {
|
||||||
go watchTip(&tipGoroot)
|
go watchTip(&tipGoroot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@ import (
|
||||||
"golang.org/x/website/internal/webtest"
|
"golang.org/x/website/internal/webtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
isTestBinary = true
|
||||||
|
}
|
||||||
|
|
||||||
func TestWeb(t *testing.T) {
|
func TestWeb(t *testing.T) {
|
||||||
h := NewHandler("../../_content", runtime.GOROOT())
|
h := NewHandler("../../_content", runtime.GOROOT())
|
||||||
files, err := filepath.Glob("testdata/*.txt")
|
files, err := filepath.Glob("testdata/*.txt")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче