doushi3803 2017-02-13 16:41
浏览 50
已采纳

将cmd文件夹中的golang应用程序部署到AWS Beanstalk

I have a pre-existing golang project with the a following folder structure (minimized the folder for readability).

- postgre
    - service.go
- cmd
    - vano
        - main.go
    - vanoctl
        - main.go
vano.go

Now since my project web server is in ./cmd/vano I need to create a custom Buildfile and Procfile. So I did that

Here is my Buildfile

make: ./build.sh

build.sh file:

#!/usr/bin/env bash

# Install dependencies.
go get ./...
# Build app
go build ./cmd/vano -o bin/application

and finally my Procfile:

web: bin/application

So now my folder structure looks like this:

- postgre
    - service.go
- cmd
    - vano
        - main.go
    - vanoctl
        - main.go
vano.go
Buildfile
build.sh
Procfile

I zip up the source using git:

git archive --format=zip HEAD > vano.zip

And upload it to AWS Beanstalk. How ever I keep getting errors and AWS errors don't seem to be the most read. Here is my error

Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

Error Message

[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.

Extra Error info:

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'
  • 写回答

1条回答 默认 最新

  • duanqilupinf67040 2017-02-22 00:05
    关注

    Another approach here instead of using a procfile etc would be to cross-compile your binary (usually pretty painless in go) and upload it that way, as per the simple instructions in the guide:

    http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html

    You can just compile it locally with:

    GOARCH=amd64 GOOS=linux go build -o bin/application ./cmd/vano 
    

    Then upload zip of the application file and it should work, assuming your setup only requires this one binary to run.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作