在AppEngine上的Go中永远不会调用/ _ah / start

时间:2016-05-26 11:35:18

标签: google-app-engine go gae-module

当我将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))
}

的app.yaml:

application: my-app
version: 1
runtime: go
api_version: go1

handlers:
- url: /.*
  secure: always
  script: _go_app

1 个答案:

答案 0 :(得分: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

相关问题