我在执行AfterInstall挂钩中的install_dependencies.sh脚本时遇到麻烦-
在AfterInstall挂钩期间,似乎我的CodeDeploy代理试图从中运行脚本的部署归档文件还不存在。
我收到此错误,导致我的部署失败:
ERROR [codedeploy-agent(2643)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform:
InstanceAgent::Plugins::CodeDeployPlugin::ScriptError -
Script does not exist at specified location: /opt/codedeploy-agent/deployment-root/432f58a2-27d7-46c0-8091-1625eb8733af/d-Q3DGM6LPU/deployment-archive/scripts/install_dependencies.sh -
/opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/hook_executor.rb:118:in `block (2 levels) in execute'...
我的appspec.yml文件如下:
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/myApp
hooks:
AfterInstall:
- location: scripts/install_dependencies.sh
timeout: 300
runas: root
ApplicationStop:
- location: scripts/stop_server.sh
timeout: 300
runas: root
ApplicationStart:
- location: scripts/start_server.sh
timeout: 300
runas: root
为了在失败的部署尝试之后访问Deployment-archive文件夹,我的确将文件放在其正确路径(错误日志中出现的相同路径)中:
[ec2-user@ip-172-31-10-87 scripts]$ cd /opt/codedeploy-agent/deployment-root/432f58a2-27d7-46c0-8091-1625eb8733af/d-Q3DGM6LPU/deployment-archive/scripts/
[ec2-user@ip-172-31-10-87 scripts]$ ls -ln
total 12
-rwxrwxrwx 1 0 0 261 Aug 21 13:33 install_dependecies.sh
-rwxrwxrwx 1 0 0 69 Aug 21 13:33 start_server.sh
-rwxrwxrwx 1 0 0 56 Aug 21 13:33 stop_server.sh
我的EC2实例操作系统是-
[ec2-user@ip-172-31-10-87 ~]$ cat /etc/issue
Amazon Linux AMI release 2018.03
[ec2-user@ip-172-31-10-87 ~]$ uname -a
Linux ip-172-31-10-87 4.14.62-65.117.amzn1.x86_64 #1 SMP Fri Aug 10 20:03:52
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
我已经检查了执行权限,并且脚本文件的内容为空(仅带有“ exit 0”语句),以帮助沙盒解决问题。
据我在所有示例中看到的-脚本文件夹应该位于我已部署的程序包中,而不位于我的部署之外。
我的appspec.yml位于项目的根文件夹中,脚本文件夹也是如此。
我想念什么?为什么在AfterInstall / BeforeInstall钩子期间无法访问这些文件?
请帮助, 谢谢