gpt4 book ai didi

go - 无法将 go lang 应用程序部署到 AWS Elastic Beanstalk

转载 作者:IT王子 更新时间:2023-10-29 02:01:23 27 4
gpt4 key购买 nike

以下是我压缩文件之前文件的组织方式。

├── app
│ ├── main.go
│ ├── Procfile
│ ├── Buildfile
│ ├── build.sh

构建文件

make: ./build.sh

构建.sh

#!/usr/bin/env bash

# Install dependencies.
go get ./...

# Build app
go build ./ -o bin/application

简介

web: bin/application

我得到的错误

[Instance: i-03f3c230e7b575431] Command failed on instance. Return code: 1 Output: (TRUNCATED)... inflating: /var/app/staging/app/main.go Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable. Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/01_configure_application.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

更多错误日志

Application update failed at 2018-10-02T01:33:44Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/01_configure_application.sh failed.

Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
Archive: /opt/elasticbeanstalk/deploy/appsource/source_bundle
creating: /var/app/staging/app/
inflating: /var/app/staging/app/Buildfile
inflating: /var/app/staging/app/build.sh
inflating: /var/app/staging/app/Procfile
inflating: /var/app/staging/app/main.go
Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.
Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.
Incorrect application version ".01" (deployment 29). Expected version ".01" (deployment 18).

我的 main.go 文件有第三方包。我正在使用

port := os.Getenv("PORT")
if port == "" {
port = "5000"
log.Println("[-] No PORT environment variable detected. Setting to ", port)
}

就像文档在示例应用程序中所说的那样。它在本地编译和运行没问题。

最佳答案

如您在错误消息中所见:

无法启动应用程序,因为源包不包含构建文件、Procfile 或可执行文件。

您的 Procfile、Buildfile 和 build.sh 应该位于项目的根目录中,如下所示:

├── app
│ ├── main.go
│ Procfile
│ Buildfile
│ build.sh

关于go - 无法将 go lang 应用程序部署到 AWS Elastic Beanstalk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52600975/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com