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?
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.
Elastic Beanstalk lets you enter the environment variables for each environment using the management panel. On AWS, open Elastic Beanstalk. Go to your Application > Environment > Configuration > Software Configuration . Under Environment Properties you will find a list of properties you can configure.
In AWS Elastic Beanstalk, you can create a load-balanced, scalable environment or a single-instance environment. The type of environment that you require depends on the application that you deploy.
Worker environments run a daemon process provided by Elastic Beanstalk. This daemon is updated regularly to add features and fix bugs. To get the latest version of the daemon, update to the latest platform version.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With