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,
|
||||
// given the directory where the content can be found
|
||||
// (can be "", in which case an internal copy is used)
|
||||
|
@ -144,12 +146,6 @@ 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
|
||||
|
||||
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
|
||||
|
@ -163,6 +159,7 @@ func NewHandler(contentDir, goroot string) http.Handler {
|
|||
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")
|
||||
|
|
Загрузка…
Ссылка в новой задаче