将环境变量设置为管理程序脚本内的另一个环境变量

时间:2014-04-09 16:40:20

标签: environment-variables supervisord

我正在尝试将环境变量设置为主管内的另一个环境变量。这是一个例子:

[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

我可以将env设置为字符串,一切正常。有没有办法将env var设置为另一个env var?感谢。

1 个答案:

答案 0 :(得分:2)

虽然这不是最佳解决方案,但我基本上将其转换为bash shell,如下所示:

[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

工作,但不漂亮