[英]Running go program on Google Cloud Run without listening for incoming HTTP requests
I wrote a Go program which doesn't need to retrieve external http calls at all by default.我编写了一个 Go 程序,默认情况下根本不需要检索外部 http 调用。 I tried to deploy it on Google Cloud Run and received the following error:
我尝试在 Google Cloud Run 上部署它并收到以下错误:
The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable.
用户提供的容器无法启动和侦听 PORT=8080 环境变量提供的端口。 Logs for this revision might contain more information.
此修订的日志可能包含更多信息。
I understand it happens because my code doesn't provide a port.我理解这是因为我的代码没有提供端口。 As this answer states:
正如这个答案所说:
container must listen for incoming HTTP requests on the port that is defined by Cloud Run and provided in the $PORT environment variable
容器必须在 Cloud Run 定义并在 $PORT 环境变量中提供的端口上侦听传入的 HTTP 请求
My question is what can I do if wouldn't like define any ports and just want to run the same code I run locally?我的问题是,如果不想定义任何端口并且只想运行我在本地运行的相同代码,我该怎么办? Is there an alternate solution to deploy my code without it, or I must add it anyway if I want run the code from Cloud Run?
是否有替代解决方案可以在没有它的情况下部署我的代码,或者如果我想从 Cloud Run 运行代码,我必须添加它?
For containers that do not require an HTTP listener (HTTP server), use Cloud Run Jobs.对于不需要 HTTP 侦听器(HTTP 服务器)的容器,请使用 Cloud Run Jobs。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.