简体   繁体   English

将简单的 Go Webapp 部署到 Elastic Beanstalk

[英]Deploy Simple Go Webapp to Elastic Beanstalk

I am trying to deploy a Go app to Elastic beanstalk (through the UI)我正在尝试将 Go 应用程序部署到 Elastic beanstalk(通过 UI)

What I've done:我做了什么:

  • Created a single application.go file which listens on Port 5000创建了一个监听端口 5000 的 application.go 文件
  • Compiled for Linux (set GOOS=linux and GOARCH=amd64) using the command found here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html使用此处找到的命令为 Linux(设置 GOOS=linux 和 GOARCH=amd64)编译: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html
    • go build -o bin/application application.go go build -o bin/application application.go
  • zipped the bin folder and uploaded it to Elastic Beanstalk (I've also tried uploading the file without the bin folder)压缩 bin 文件夹并将其上传到 Elastic Beanstalk(我也尝试过在没有 bin 文件夹的情况下上传文件)

For development I'm using go version go1.18.1 windows/amd64对于开发,我使用 go 版本 go1.18.1 windows/amd64

Under Platform in Elastic Beanstalk I see: Go 1 running on 64bit Amazon Linux 2/3.5.1在 Elastic Beanstalk 的平台下,我看到:Go 1 running on 64bit Amazon Linux 2/3.5.1

According to https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.go go v. 1.18.1 is supported根据https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.go go v. 1.18.1 支持

My Code:我的代码:

package main
import (
    "fmt"
    "net/http"
    "time"
)
func main() {
    http.HandleFunc("/", index)
    fmt.Println("Now serving!!!")
    http.ListenAndServe(":5000", nil)
}
func index(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "My Res !!! %s", time.Now())
}

The Application health is "no data".应用程序运行状况为“无数据”。

With the most recent event of "Environment health has transitioned from Pending to No Data. None of the instances are sending data."最近发生的事件是“环境健康状况已从待定状态转变为无数据状态。所有实例均未发送数据。”

When I look in chrome dev tools and try to open the link, I just get (failed).net:ERR_CONNECTION_RESET.当我查看 chrome 开发工具并尝试打开链接时,我只是得到 (failed).net:ERR_CONNECTION_RESET。 "Failed to load response data: No Resource with given identifier found" “无法加载响应数据:找不到具有给定标识符的资源”

Potential Issues:潜在问题:

  • When I look at the configuration tab, I see that this environment is not part of a VPC.当我查看配置选项卡时,我发现此环境不是 VPC 的一部分。 Could that be the issue?这可能是问题所在吗?

Some Potential Next Steps:一些潜在的后续步骤:

  • Test running on WSL测试在 WSL 上运行
  • Test deploying on a standalone EC2在独立的 EC2 上测试部署
  • Try deploying through the CLI尝试通过 CLI 进行部署
  • Try wrapping in a docker container and deploying docker (though this wouldn't actually solve my problem, I'd like to be able to deploy without docker)尝试包装在 docker 容器中并部署 docker(尽管这实际上不能解决我的问题,但我希望能够在没有 docker 的情况下进行部署)

I tried to replicate your issue using your code, but everything is fine .我尝试使用您的代码复制您的问题,但一切都很好 My EB environment works and deploys perfectly with your code.我的 EB 环境可以与您的代码完美配合和部署。

The only thing I can think of is that I used linux to create my binary, while you've used windows/amd64 .我唯一能想到的是我使用 linux 来创建我的二进制文件,而您使用的是windows/amd64 I don't think those binaries are interchangeable.我不认为这些二进制文件是可以互换的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM