当我将我的 Go 应用程序部署到 GAE 时,永远不会调用 /_ah/start
端点。当我运行以下代码时,日志不包含“STARTING”条目并且 /
没有设置 X
。
我错过了什么?
server.go:
package main
import (
"net/http"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
)
var X string
func init() {
http.HandleFunc("/_ah/start", start)
http.HandleFunc("/", meh)
}
func start(w http.ResponseWriter, r *http.Request) {
X = "!!!!!"
c := appengine.NewContext(r)
log.Infof(c, "STARTING")
}
func meh(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("The value is: " + X))
}
应用程序.yaml:
application: my-app
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
secure: always
script: _go_app
最佳答案
具有手动缩放功能的 app.yml。
application: my-app
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
secure: always
script: _go_app
instance_class: B8
manual_scaling:
instances: 5
关于google-app-engine -/_ah/start 在 AppEngine 上的 Go 中从未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37459724/