我有一个预先存在的golang项目,其中包含以下文件夹结构(为了便于阅读,最小化了文件夹)。
- postgre
- service.go
- cmd
- vano
- main.go
- vanoctl
- main.go
vano.go
现在,由于我的项目网络服务器位于./cmd/vano
,我需要创建自定义Buildfile
和Procfile
。所以我做了那个
这是我的Buildfile
make: ./build.sh
build.sh文件:
#!/usr/bin/env bash
# Install dependencies.
go get ./...
# Build app
go build ./cmd/vano -o bin/application
最后是我的Procfile:
web: bin/application
所以现在我的文件夹结构如下所示:
- postgre
- service.go
- cmd
- vano
- main.go
- vanoctl
- main.go
vano.go
Buildfile
build.sh
Procfile
我使用git压缩源:
git archive --format=zip HEAD > vano.zip
并将其上传到AWS Beanstalk。我如何不断收到错误,AWS错误似乎并不是最常见的。这是我的错误
Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
错误消息
[Instance: i-0d8f642474e3b2c68] Command failed on instance. Return code: 1 Output: (TRUNCATED)...' Failed to execute 'HOME=/tmp /opt/elasticbeanstalk/lib/ruby/bin/ruby /opt/elasticbeanstalk/lib/ruby/bin/foreman start --procfile /tmp/d20170213-1941-1baz0rh/eb-buildtask-0 --root /var/app/staging --env /var/elasticbeanstalk/staging/elasticbeanstalk.env'. 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.
额外错误信息:
Failed to execute 'HOME=/tmp /opt/elasticbeanstalk/lib/ruby/bin/ruby /opt/elasticbeanstalk/lib/ruby/bin/foreman start --procfile /tmp/d20170213-1941-1baz0rh/eb-buildtask-0 --root /var/app/staging --env /var/elasticbeanstalk/staging/elasticbeanstalk.env'
答案 0 :(得分:2)
这里的另一种方法,而不是使用procfile等,将交叉编译你的二进制文件(通常很简单),并按照指南中的简单说明上传它:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html
您可以使用以下命令在本地编译它:
GOARCH=amd64 GOOS=linux go build -o bin/application ./cmd/vano
然后上传应用程序文件的zip,它应该有效,假设您的设置只需要运行这一个二进制文件。