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:
Russ Cox 2021-07-16 10:39:37 -04:00
Родитель f4281e3dec
Коммит 42b41e29af
2 изменённых файлов: 18 добавлений и 17 удалений

Просмотреть файл

@ -113,6 +113,8 @@ func main() {
}
}
var isTestBinary = false
// NewHandler returns the http.Handler for the web site,
// given the directory where the content can be found
// (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)
}
// When we are ready to start serving tip.golang.org
// from the default golang-org app instead of a separate app,
// we can set serveTip = true.
const serveTip = false
// tip.golang.org serves content from the very latest Git commit
// of the main Go repo, instead of the one the app is bundled with.
var tipGoroot atomicFS
if _, err := newSite(mux, "tip.golang.org", content, &tipGoroot); err != nil {
log.Fatalf("loading tip site: %v", err)
}
if serveTip {
// tip.golang.org serves content from the very latest Git commit
// of the main Go repo, instead of the one the app is bundled with.
var tipGoroot atomicFS
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)
}
// 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)
}

Просмотреть файл

@ -12,6 +12,10 @@ import (
"golang.org/x/website/internal/webtest"
)
func init() {
isTestBinary = true
}
func TestWeb(t *testing.T) {
h := NewHandler("../../_content", runtime.GOROOT())
files, err := filepath.Glob("testdata/*.txt")