Amazon Web Service CodeDeploy appspec.yml problems

痞子三分冷 提交于 2019-11-30 12:45:40

问题


I have a Node.js application which is being automatically deployed to Amazon Web Service through Codeship using the CodeDeploy AWS deployment system.

During the deployment process I've set in my appspec.yml for the currently running web application to be stopped. Once the deployment is complete, I want the web application to be started up again.

os: linux
files:
  - source: /
    destination: /var/www/app2
hooks:
  AfterInstall:
      - location: bash_scripts/stop_forever.sh
        runas: ec2-user
  ApplicationStart:
      - location: bash_scripts/start_forever.sh
        runas: ec2-user

However I've not yet been able to have either of these scripts to be called successfully from the appspec.yml file during a deployment.

The current error I'm seeing in the AWS deployment agent log is

Error CodeScriptMissing
Script Name /var/scripts/stop_forever.sh
MessageScript does not exist at specified location: /var/scripts/stop_forever.sh
Log TailLifecycleEvent - ApplicationStop

This seems to refer to an older version of the appspec.yml file which was attempting to run these scripts in a different location. Even though I've changed the contents of the appspec.yml file in the deployed package, this error message remains the same on each deploy.

In addition to appspec.yml file listed above, I've also tried making the following changes:

  • Not listing a runas parameter for each hook
  • Referencing a script inside the deployed directory
  • Referencing a script outside the deployed directory
  • Having a version parameter initially set to 0.0

Unfortunately there is very little online in terms of appspec.yml troubleshooting, other than the AWS documentation.

What very obvious thing I am doing wrong?


回答1:


The ApplicationStop hook is being called from the previously installed deployment before trying to run the current deployment appspec.yml file.

In order to prevent this from happening you'll have to remove any previously installed deployment from the server.

  • Stop the code deploy agent - sudo service codedeploy-agent stop
  • clear all deployments under /opt/codedeploy-agent/deployment-root
  • Restart the code deploy agent - sudo service codedeploy-agent start



回答2:


There is another way documented in the AWS developer forums, which I think is preferable.

Use the --ignore-application-stop-failures option with the CLI tool while doing the deployment, it worked perfectly for me.

Example taken from the forum:

aws deploy create-deployment --application-name APPLICATION --deployment-group-name GROUP --ignore-application-stop-failures --s3-location bundleType=tar,bucket=BUCKET,key=KEY --description "Ignore ApplicationStop failures due to broken script"

https://forums.aws.amazon.com/thread.jspa?threadID=166904



来源:https://stackoverflow.com/questions/27923991/amazon-web-service-codedeploy-appspec-yml-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!