根据 Docs :
entrypoint
Optional. Overrides the default startup behavior by executing the entrypoint command when your app starts. For your app to receive HTTP requests, the entrypoint element should contain a command which starts a web server that listens on port 8080.
我将如何配置它?在任何地方都找不到详细信息。
我可以这样做吗?
entrypoint: go run main.go fooArg --bar-flag=1
我没有云构建文件,只有 app.yaml。那么是什么入口点 真的吗?当应用引擎到达 入口点 部分程序是否已经编译?
谢谢
最佳答案
我刚刚在我自己的 GCP AppEngine 项目中尝试了这个,并使用了 entrypoint
(例如 entrypoint: go run ./cmd/web prod
)对我不起作用。当我尝试它时,我收到了这个神秘的错误消息:
Error type: UNKNOWN
Error message: no Go files in /layers/google.go.appengine_gomod/srv
我正在使用 Google Cloud SDK 344.0.0
.我和你的情况类似,尽管我只是想通过
args
进入我的 golang main。关注 the docs ,我改用 env_variables
相反,哪个有效。我的 app.yaml 看起来像:
runtime: go115
main: ./cmd/web
env_variables:
APP_ENV: "prod"
然后在我的代码中,我只是使用 os.Getenv("APP_ENV")
任何地方都可以访问。
关于go - 如何在 app.yaml 中为 Go 传递运行参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67843806/