在压缩文件之前,这是文件的组织方式。
├── app
│ ├── main.go
│ ├── Procfile
│ ├── Buildfile
│ ├── build.sh
Buildfile
make: ./build.sh
build.sh
#!/usr/bin/env bash
# Install dependencies.
go get ./...
# Build app
go build ./ -o bin/application
Procfile
web: bin/application
我得到的错误
[实例:i-03f3c230e7b575431]命令在实例上失败。返回码:1输出:(TRUNCATED)...膨胀:/var/app/staging/app/main.go由于源包中不包含Buildfile,Procfile或可执行文件,因此无法启动应用程序。由于源包中不包含Buildfile,Procfile或可执行文件,因此无法启动应用程序。挂钩/opt/elasticbeanstalk/hooks/appdeploy/pre/01_configure_application.sh失败。有关更多详细信息,请使用控制台或EB CLI检查/var/log/eb-activity.log。
更多错误日志
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)
}
就像文档在示例应用程序中所说的那样。它可以在本地编译和运行。
答案 0 :(得分:2)
您会在错误消息中看到:
由于源包中不包含Buildfile,Procfile或可执行文件,因此无法启动应用程序。
您的Procfile,Buildfile和build.sh应该位于项目的根目录中,如下所示:
├── app
│ ├── main.go
│ Procfile
│ Buildfile
│ build.sh