【问题标题】:Setting an environment variable to another environment variable inside of a supervisor script在主管脚本中将环境变量设置为另一个环境变量
【发布时间】:2014-05-23 00:37:00
【问题描述】:

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

[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 设置为字符串,一切正常。有没有办法将环境变量设置为另一个环境变量?谢谢。

【问题讨论】:

  • 我已经能够通过删除“环境”修改“命令”来做到这一点,如下所示: command = /bin/bash -c 'export REDIS_URL=$REDIS_PORT && node /usr/src/ iodocs/app.js' 但这似乎很老套
  • 为什么这个标签是nodejs?你说的是nodejs的环境变量还是简单的bash脚本?
  • 可能不应该 - 认为可能有一种方法可以使用环境变量调用节点。我会删除。

标签: environment-variables supervisord


【解决方案1】:

虽然这不是最佳解决方案,但我基本上将其放入 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

有效,但不漂亮

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    • 2014-01-29
    相关资源
    最近更新 更多