简体   繁体   English

AWS Elastic Beanstalk部署顺序

[英]AWS Elastic Beanstalk Deployment Order

I'm deploying code to a single-instance web server AWS EB environment that will provision/update my connected RDS database. 我正在将代码部署到单实例Web服务器AWS EB环境中,该环境将配置/更新我连接的RDS数据库。 I've got an .ebextensions file that calls deployment code: 我有一个.ebextensions文件,该文件调用部署代码:

---
container_commands:
  01deploydb:
    command: /var/www/html/php/cli/deploy-db.php
    leader_only: true

On the same deployment, I dropped the deploy-db.php file back one directory into /cli/ . 在同一部署中,我将deploy-db.php文件放回一个目录到/cli/ On deployment, I get ERROR: [Instance: i-*****] Command failed on instance. Return code: 127 Output: /bin/sh: /var/www/html/php/cli/deploy-db.php: No such file or directory. container_command 01deploydb in .ebextensions/01_db.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI. 在部署时,出现ERROR: [Instance: i-*****] Command failed on instance. Return code: 127 Output: /bin/sh: /var/www/html/php/cli/deploy-db.php: No such file or directory. container_command 01deploydb in .ebextensions/01_db.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI. ERROR: [Instance: i-*****] Command failed on instance. Return code: 127 Output: /bin/sh: /var/www/html/php/cli/deploy-db.php: No such file or directory. container_command 01deploydb in .ebextensions/01_db.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

If I deploy a version that does not include the command, then deploy a second update including the command, there is no error. 如果我部署的版本不包含该命令,则部署第二个包含该命令的更新,则没有错误。 However, adding the command and the file it calls at the same time produces the error. 但是,同时添加命令和它调用的文件会产生错误。 A similar sequence occurred earlier with a different command/file. 先前使用不同的命令/文件发生了类似的顺序。

My question is: is there a documented order/sequence for how AWS updates the environment? 我的问题是:AWS如何更新环境是否有记录的订单/顺序? I would have expected that my new version would have fully deployed (and the .php file installed) before container_commands are called. 我希望在调用container_commands之前,我的新版本将完全部署(并安装.php文件)。

The commands: section runs before the project files are put in place. 命令:部分在放置项目文件之前运行。 This is where you can install server packages for example. 例如,您可以在此处安装服务器软件包。

The container_commands: section runs in a staging directory before the files are put in its final destination. container_commands:节在将文件放入其最终目的地之前,在暂存目录中运行。 Here you can modify your files if you need to. 如果需要,您可以在此处修改文件。 Current path is this staging directory so you can run it like this (I might get the app directory wrong, maybe it should be php/cli/deploy-db.php ) 当前路径是此暂存目录,因此您可以像这样运行它(我可能将应用程序目录弄错了,也许应该是php/cli/deploy-db.php

container_commands:
  01deploydb:
    command: cli/deploy-db.php
    leader_only: true

Reference for above: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html 上面的参考: http : //docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

You can also run a post deploy scripts. 您还可以运行部署后脚本。 This is not very well documented (at least it wasn't). 这没有很好的记录(至少没有记录)。 You can do something like this (it won't be leader only though, but you could put a file in this directory through a container_commands: ): 您可以执行以下操作(尽管它不会成为领导者,但是您可以通过container_commands:将文件放在此目录中):

files:
    "/opt/elasticbeanstalk/hooks/appdeploy/post/99_deploy.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
            #!/usr/bin/env bash
            /var/www/html/php/cli/deploy-db.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM