Beanstalk 中的commands 和container_commands 配置键有什么区别? [英] What is the difference between commands and container_commands configuration keys in Beanstalk?

查看:22
本文介绍了Beanstalk 中的commands 和container_commands 配置键有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在 .ebextensions 中设置 Elastic Beanstalk 扩展时

When we setup Elastic Beanstalk extensions in .ebextensions

我想知道 Beanstalk 配置文件键中的 commandscontainer_commands 有什么区别.

I wonder what is the difference between commands and container_commands in Beanstalk configuration file keys.

我的命令是这样的

container_commands:
  04_insert_app:
    command: "cat .ebextensions/insertapp_job.txt > /etc/cron.d/insertapp_job && chmod 644 /etc/cron.d/insertapp_job"
    leader_only: true

container_commands 工作正常.

container_commands works fine.

commands: has error .ebextensions/insertapp_job.txt not found

commands: has error .ebextensions/insertapp_job.txt not found

推荐答案

这两个部分的主要区别在于它们在 Elastic Beanstalk 部署过程中的运行时间.

The major difference between these two pieces is when in the Elastic Beanstalk deployment process they are run.

这些命令在部署过程的早期运行,在设置 Web 服务器之前,以及在解压应用程序代码之前:

These commands are run early in the deployment process, before the web server has been set up, and before your application code has been unpacked:

命令按名称的字母顺序进行处理,并在设置应用程序和 Web 服务器以及提取应用程序版本文件之前运行.1

The commands are processed in alphabetical order by name, and they run before the application and web server are set up and the application version file is extracted.1

默认情况下,命令在 root 用户的主文件夹中运行.可以通过可以与命令一起传递的选项(工作目录、是否继续出错、传递给命令的环境变量等)来更改 EB 的这一行为和其他各种行为.

By default, the commands run in the root user's home folder. This and various other pieces of EB's behavior can be changed via options (working directory, whether to continue on error, environment variables to pass to commands, etc.) that can be passed along with the command.

这些命令在部署过程的后期运行,在设置 Web 服务器之后,在您的应用程序代码解压到暂存文件夹之后,但在您的应用程序部署"之前(通过移动暂存文件夹)到其最终位置):

These commands are run later in the deployment process, after the web server has been set up, and after your application code has been unpacked to the staging folder, but before your application has been "deployed" (by moving the staging folder to its final location):

容器命令在应用程序和 Web 服务器设置完毕并提取应用程序版本存档之后运行,但在部署应用程序版本之前运行.在提取应用程序源代码之前执行非容器命令和其他自定义操作.2

Container commands run after the application and web server have been set up and the application version archive has been extracted, but before the application version is deployed. Non-container commands and other customization operations are performed prior to the application source code being extracted.2

默认情况下,这些命令在暂存文件夹中运行,因此您对当前文件夹所做的任何更改都将在您的应用程序部署后保留(尽管路径会更改,因此请注意相关链接!).

By default, these commands run in the staging folder, so that any changes you make to the current folder will persist once your application is deployed (the path will change though, so be careful about relative links!).

容器命令支持所有与(非容器)命令相同的选项,但它们也支持leader_only"选项:

Container commands support all the same options as (non-container) commands, but they also support a "leader_only" option:

您可以使用 leader_only 仅在单个实例上运行该命令,或者将测试配置为仅在测试命令评估为 true 时运行该命令.Leader-only 容器命令仅在环境创建和部署期间执行,而其他命令和服务器定制操作则在每次配置或更新实例时执行.2

You can use leader_only to only run the command on a single instance, or configure a test to only run the command when a test command evaluates to true. Leader-only container commands are only executed during environment creation and deployments, while other commands and server customization operations are performed every time an instance is provisioned or updated.2

这篇关于Beanstalk 中的commands 和container_commands 配置键有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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