4

当我将 Go 应用程序部署到 GAE 时,/_ah/start永远不会调用端点。当我运行以下代码时,日志不包含“STARTING”条目并且/没有X设置。

我错过了什么?

服务器.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
4

1 回答 1

2

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

https://cloud.google.com/appengine/docs/go/an-overview-of-app-engine#scaling_types_and_instance_classes

于 2016-06-03T00:31:17.987 回答