AWS编码器未运行挂钩脚本
我正在学习如何使用Codepipeline并在小型测试节点应用程序中遇到CodeDeploy的问题。我的目标是实现大型Express + React应用程序的CD,我需要使用AppSpec.yml的钩子。 目前,其他所有内容都在起作用,复制文件等,它只是没有触发脚本。我从启动之前(从pm2删除进程)和applicationstart(使用pm2启动应用程序)挂钩开始,但是现在我切换到使用脚本使用applicationstart将其从pm2中删除PM2,以查看它是否有效。
我的appspec.yml:
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/api
permissions:
- object: /home/ubuntu/api/
owner: ubuntu
group: ubuntu
mode: "777"
# I use appStop.sh just to check if this works:
ApplicationStart:
- location: scripts/appStop.sh
runas: ubuntu
# I tried also running as root, still nothing
timeout: 60
appstop.sh:
#!/bin/bash
cd /home/ubuntu/api
pm2 delete 0
我尝试了很多事情,也将所有内容都作为根(尽管我更喜欢使用ubuntu用户)。
在/var/log/aws/codedeploy-agent中,日志文件中没有错误。
我还可以在Revieev中看到所有文件和脚本DIR/opt/opt/codedeploy-agent/deployment-root/...
当我在家中手动运行appstop脚本时,我可以正常工作。 看起来编码eploy代理只是没有运行脚本。
I'm learning how to use CodePipeline and have problem with CodeDeploy for small testing node app. My target is to implement CD for large express + react app and I need to use hooks from AppSpec.yml.
For now everything else is working, files are copied etc, it just doesn't fire script. I started with BeforeInstall (delete process from pm2) and ApplicationStart (start app with pm2) hooks, but now I switched to using ApplicationStart with script to remove process from pm2 just to see if it works.
My AppSpec.yml:
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/api
permissions:
- object: /home/ubuntu/api/
owner: ubuntu
group: ubuntu
mode: "777"
# I use appStop.sh just to check if this works:
ApplicationStart:
- location: scripts/appStop.sh
runas: ubuntu
# I tried also running as root, still nothing
timeout: 60
appStop.sh:
#!/bin/bash
cd /home/ubuntu/api
pm2 delete 0
I tried many things, also running everything as root (though I prefer to use ubuntu user).
There are no ERRORs in log file in /var/log/aws/codedeploy-agent.
I can also see all files and scripts dir in reviev in /opt/codedeploy-agent/deployment-root/...
When I manually run appStop script in home dir it works.
It looks like CodeDeploy agent is just not running script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,看来我使它起作用。
首先,我通过删除
/opt/opt/deployment-root/< exployment droup id>
dir and/opt/opt/deployment-root/deployment-instructions
我也 清洁了编码EPLOY-ADENT数据更改了位置,不知道这是否有帮助,但是必须这样做,因为我决定与Root用户一起使事情变得更容易。应用程序现在在/var/www/api中。
我还使用
sudo
my working appspec.yml:
and working scripts:
appstop.sh:
appstart.sh:
Ok it seems I made it work.
First I cleaned codedeploy-agent data by removing
/opt/deployment-root/<deployment droup id>
dir and/opt/deployment-root/deployment-instructions
I also changed location, don't know if this helped, but had to do it since I decided to go with root user to make things easier. App is now in /var/www/api.
I also reinstalled all js software (node, pm2, npm) using
sudo
My working AppSpec.yml:
and working scripts:
appStop.sh:
appStart.sh: