Amazon Web Service CodeDeploy appspec.yml 问题 [英] Amazon Web Service CodeDeploy appspec.yml problems

查看:18
本文介绍了Amazon Web Service CodeDeploy appspec.yml 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Node.js 应用程序,它通过 自动部署到 Amazon Web ServiceCodeship 使用 CodeDeploy AWS 部署系统.

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

在部署过程中,我在 appspec.yml 中设置了当前正在运行的 Web 应用程序要停止.部署完成后,我希望再次启动 Web 应用程序.

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

但是我还不能在部署期间从 appspec.yml 文件中成功调用这两个脚本.

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.

我在 AWS 部署代理日志中看到的当前错误是

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

这似乎是指旧版本的 appspec.yml 文件,它试图在不同的位置运行这些脚本.即使我更改了已部署包中 appspec.yml 文件的内容,此错误消息在每次部署时都保持不变.

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.

除了上面列出的 appspec.yml 文件之外,我还尝试进行以下更改:

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

  • 未列出每个挂钩的 runas 参数
  • 在部署目录中引用脚本
  • 在部署目录之外引用脚本
  • version 参数初始设置为 0.0
  • 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

不幸的是,除了 AWS 文档.

我做错了什么非常明显的事情?

What very obvious thing I am doing wrong?

推荐答案

在尝试运行当前部署 appspec.yml文件.

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.

  • 停止代码部署代理 - sudo service codedeploy-agent stop
  • 清除 /opt/codedeploy-agent/deployment-root 下的所有部署
  • 重启代码部署代理——sudo service codedeploy-agent start

这篇关于Amazon Web Service CodeDeploy appspec.yml 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆