在哪里放置仅在启动时运行一次的Elastic Beanstalk配置命令? [英] Where to put Elastic Beanstalk config commands that are only run once on spin-up?

查看:184
本文介绍了在哪里放置仅在启动时运行一次的Elastic Beanstalk配置命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用命令将命令放在.ebextensions / *。config中的源代码中。这些都是在个部署执行。

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?

推荐答案

命令可以有条件地运行使用 test:修饰符。您指定要完成的测试。如果测试返回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


$ b b

在Windows上,它将是这样的

On Windows it would be something like this

commands:
  01-do-always:
    command: run_my_script
  02-do-on-boot:
    command: script_to_run_once
    test: if exists c:\\path\\to\\semaphore.txt (exit 0) else (exit 1)
  99-signal-startup-complete:
    command: date > c:\\path\\to\\semaphore.txt

这篇关于在哪里放置仅在启动时运行一次的Elastic Beanstalk配置命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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