EC2使用CodeDeploy部署golang应用程序



我正在尝试使用CodeDeploy将一个简单的golang Web服务器部署到EC2。部署失败,出现以下错误{"error_code":6,"script_name":"scripts/start.sh","message":"Script at specified location: scripts/start.sh failed to close STDOUT"。CodeDeploy相关文件:

appspec.yml

version: 0.0
os: linux
files:
- source: /main.go
destination: /app/
- source: /index.html
destination: /app/
- source: /config.json
destination: /app/
- source: /webserver.log
destination: /app/
hooks:
BeforeInstall:
- location: scripts/cleanup.sh
timeout: 180
runas: root
AfterInstall:
- location: scripts/build.sh
timeout: 180
runas: root
ApplicationStart:
- location: scripts/start.sh
timeout: 180
runas: root

scripts/cleanup.sh

sudo rm /app -rf
sudo mkdir /app
sudo chown -R ec2-user:ec2-user /app
sudo yum update -y
sudo yum install -y golang

scripts/build.sh

go build -o /app/webserver /app/main.go

scripts/start.sh

/app/webserver &

我想这与我如何启动服务器有关,但我不擅长Linux的复杂性,所以非常感谢更详细的解释。

完整的Web服务器源代码可以在github中找到。

我认为它与stdout, stderr, and stdin:有关

在&

/dev/null 2> /dev/null < /dev/null

相关内容

最新更新