我是AWS CodeDeploy的新手,事实上,我只是在试验。
我正在尝试使用CircleCI 2.0和AWS CodeDeploy来处理持续集成,这样当我将我的django项目的更改推送到github中的开发时,它会在CircleCI中构建,然后将部署推送到S3,之后更改是部署到EC2。
我在CodeDeploy中完成了所有配置,并且我从github中使用了CodeDeploy和Django / DRF项目(例如我的)的人复制了appspec。唯一的区别是他在他的EC2实例中使用了另一个内核(我认为AWS linux)并且我正在使用ubuntu。因此,我必须更改每个runas
部分的hooks
部分中的用户名。我第一次在aws cli中运行create-deployment命令时,部署失败并显示以下消息:
LifecycleEvent - ApplicationStop
Script - scripts/stop_application.sh
[stderr]No passwd entry for user 'ec2-user'
事实证明,我忘了更改runas
挂钩中的ApplicationStop
使用者。然后我改变它,再次进行推送和创建部署,但错误仍然是相同的。我是否需要为appspec中的更改做些其他事情,或者为什么会这样?
以下是 appspec.yml 文件:
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/taptop_web
permissions:
- object: /home/ubuntu
pattern: "**"
owner: ubuntu
group: ubuntu
hooks:
BeforeInstall:
- location: scripts/clean_instance.sh
timeout: 6000
runas: root
AfterInstall:
- location: scripts/install_os_dependencies.sh
timeout: 6000
runas: root
- location: scripts/install_python_dependencies.sh
timeout: 6000
runas: ubuntu
- location: scripts/migrate.sh
timeout: 6000
runas: ubuntu
ApplicationStart:
- location: scripts/start_application.sh
timeout: 6000
runas: ubuntu
ApplicationStop:
- location: scripts/stop_application.sh
timeout: 6000
runas: ubuntu
stop_application.sh
#!/usr/bin/env bash
cd /home/ubuntu/taptop_web
ps auxw | grep runserver | awk '{print $2}' | xargs kill
答案 0 :(得分:0)
The only thing you need to do to fix your issue is have a successful deployment. It only appears as though it didn't update because when you do the deployment, it will run ApplicationStop
from the previous revision. This is often confusing, but it works that way because only a revision should know how to stop its own application - if the stop commands changed between revisions, the new stop command wouldn't work.
That being said, it's not an uncommon issue where customers have a ApplicationStop
script that fails due to an issue in the script, so a deployment will keep failing without intervention. If there's your issue, follow this guide来传递值,以摆脱这种情况。