当把那些只在自旋向上运行一次弹性魔豆的配置命令? [英] Where to put Elastic Beanstalk config commands that are only run once on spin-up?

查看:89
本文介绍了当把那些只在自旋向上运行一次弹性魔豆的配置命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以把命令在我的源代码code在.ebextensions / *配置使用命令阵列。这些都是对的每次的部署然而执行。如果我想执行的配置命令只有一次转动了一个新的实例时约?

I know I can put commands in my source code in .ebextensions/*.config using the commands array. These are executed on every deploy however. What about if I want to execute a configuration command only once when spinning up a new instance?

推荐答案

命令可以有条件地使用试运行。您指定要进行测试。如果测试返回0,运行命令,否则就不是。

Commands can be run conditionally using the test: modifier. You specify a test to be done. If the test returns 0, the command is run, otherwise it is not.

如果在您的配置文件中的最后一个命令倒是一个文件,上面的命令,你只需要运行一次检查该文件存在,那么这些命令将只运行一次。

If the last command in your config file touches a file, and the commands above that you only want to run once check for the existence of that file, then those commands will only run the first time.

commands:
  01-do-always:
    command: run_my_script
  02-do-on-boot:
    command: script_to_run_once
    test: test ! -f .semaphore
  99-signal-startup-complete:
    command: touch .semaphore

这篇关于当把那些只在自旋向上运行一次弹性魔豆的配置命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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