Scott Switzer
Scott Switzer

Reputation: 1074

Setting an environment variable to another environment variable inside of a supervisor script

I am trying to set an environment variable to another environment variable inside of supervisor. Here is an example:

[supervisord]
nodaemon=true
loglevel = debug

[program:nodejs]
redirect_stderr = true
environment=REDIS_URL=$REDIS_PORT
directory = /usr/src/myapp/
command = node /usr/src/myapp/app.js
autostart = true
autorestart = true

I can set the env to a string, and everything works. Is there any way to set the env var to another env var? Thanks.

Upvotes: 1

Views: 1231

Answers (1)

Scott Switzer
Scott Switzer

Reputation: 1074

While this is not the optimal solution, I basically rolled this into a bash shell as follows:

[supervisord]
nodaemon=true

[program:nodejs]
user = www-data
directory = /usr/src/iodocs/
command = /bin/bash -c 'export REDIS_URL=$REDIS_PORT && node app.js'
autostart = true
autorestart = true

Works, but not pretty

Upvotes: 2

Related Questions