I deploy the same application to two different environments app-web
and app-worker
. The configuration of these environments differs slightly (e.g. they run different processes) so some different .ebextensions
will be required for each. Is there a way to specify that a certain config file should only be run for a certain environment?
我将相同的应用程序部署到两个不同的环境app-web和app-worker。这些环境的配置略有不同(例如,它们运行不同的进程),因此每个环境都需要一些不同的.ebextensions。有没有办法指定某个配置文件应该只针对特定环境运行?
Here's the config file that needs to be set for the worker environment only:
这是仅需要为工作线程环境设置的配置文件:
packages:
yum:
monit: []
files:
"/etc/monit.d/resque_worker":
mode: "000644"
owner: root
group: root
content: |
check process resque_worker_QUEUE
with pidfile /var/app/resque_worker_QUEUE.pid
start program = "/bin/sh -l -c 'cd /var/app/current; nohup rake environment resque:work QUEUE=* VERBOSE=1 PIDFILE=/var/app/resque_worker_QUEUE.pid >> log/resque_worker_QUEUE.log 2>&1'" as uid webapp and gid webapp
stop program = "/bin/sh -c 'cd /var/app/current && kill -9 $(cat tmp/pids/resque_worker_QUEUE.pid) && rm -f /var/app/resque_worker_QUEUE.pid; exit 0;'"
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
group resque_workers
commands:
remove_bak:
command: "rm /etc/monit.d/resque_worker.bak"
ignoreErrors: true
service:
sysvinit:
monit:
ensureRunning: true
enabled: true
I know I can test for the presence of an environmental variable to stop commands from running with the commands/test
, but I'm not sure what to do with the rest.
我知道我可以测试一个环境变量的存在来阻止命令运行命令/测试,但我不知道如何处理其余的。
1 个解决方案
#1
So as far as I can tell, there's no way to do this at this time, which is pretty obnoxious... I ended up writing a script which conditionally enables worker extensions for deploys.
所以据我所知,目前还没有办法做到这一点,这是非常令人讨厌的......我最终编写了一个脚本,它有条件地启用了工作扩展以进行部署。
Basically during a worker deploy, the script enables certain files by changing the extension from worker-config
to config
, create a temporary commit, deploy, then reset the commit.
基本上在工作器部署期间,脚本通过将扩展从worker-config更改为config,创建临时提交,部署,然后重置提交来启用某些文件。
#1
So as far as I can tell, there's no way to do this at this time, which is pretty obnoxious... I ended up writing a script which conditionally enables worker extensions for deploys.
所以据我所知,目前还没有办法做到这一点,这是非常令人讨厌的......我最终编写了一个脚本,它有条件地启用了工作扩展以进行部署。
Basically during a worker deploy, the script enables certain files by changing the extension from worker-config
to config
, create a temporary commit, deploy, then reset the commit.
基本上在工作器部署期间,脚本通过将扩展从worker-config更改为config,创建临时提交,部署,然后重置提交来启用某些文件。