Tam*_*mpa 63 environment-variables supervisord
我真的不知道如何让主管使用环境变量.
以下是配置代码段.
[program:htNotificationService]
priority=2
#autostart=true
#autorestart=true
directory=/home/ubuntu/workspace/htFrontEnd/heythat/htsite
command = /usr/bin/python htNotificationService.py -service
stdout_logfile=/var/log/heythat/htNotificationService.log
redirect_stderr=true
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat
stopsignal=QUIT
Run Code Online (Sandbox Code Playgroud)
我尝试过以下方法:
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat
environment=PYTHONPATH=$PYTHONPATH:/home/ubuntu/workspace/htFrontEnd/heythat
environment=PATH=/home/ubuntu/workspace/htFrontEnd/heythat,PYTHONPATH=$PYTHONPATH:/home/ubuntu/workspace/htFrontEnd/heythat
Run Code Online (Sandbox Code Playgroud)
当我开始上司时,我得到了
htNotificationService: ERROR (abnormal termination)
Run Code Online (Sandbox Code Playgroud)
我可以通过设置python路径从shell开始,但不能从主管开始.在日志中,我收到一条错误消息,指出无法找到导入.好吧,如果主管能够工作,那就可以解决.我甚至在/ etc/environment中有路径?
为什么主管不工作?
edi*_*rgy 96
使用%(ENV_VARNAME)s来引用现有的env变量
(参见https://github.com/Supervisor/supervisor/blob/master/supervisor/skel/sample.conf)
设置多个环境变量是通过用逗号分隔它们来完成的
(见http://supervisord.org/subprocess.html#subprocess-environment)
尝试:
environment=PYTHONPATH=/opt/mypypath:%(ENV_PYTHONPATH)s,PATH=/opt/mypath:%(ENV_PATH)s
Run Code Online (Sandbox Code Playgroud)
jet*_*com 24
在supervisord块下的.conf文件中,您可以添加所有环境键=值对
[supervisord]
environment=CELERY_BROKER_URL="amqp://guest:guest@127.0.0.1:5672//",FLASK_CONFIG="TESTING"
[program:celeryd]
command=celery worker -A celery --loglevel=info -P gevent -c 1000
Run Code Online (Sandbox Code Playgroud)
如果您不想对变量进行硬编码,但想从os环境中将其拉入,请在bash上执行步骤1
导出env var
>> sudo export CELERY_BROKER_URL="amqp://guest:guest@127.0.0.1:5672//"
Run Code Online (Sandbox Code Playgroud)
重新加载Bash
>> . ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
检查env vars是否设置正确
>> env
Run Code Online (Sandbox Code Playgroud)
现在修改conf文件以读取 - 注意:使用ENV_前缀env变量
[supervisord]
environment=CELERY_BROKER_URL="%(ENV_CELERY_BROKER_URL)s",FLASK_CONFIG="%(ENV_FLASK_CONFIG)s"
[program:celeryd]
command=celery worker -A celery --loglevel=info -P gevent -c 1000
Run Code Online (Sandbox Code Playgroud)
Fuz*_*Ami 16
这对我有用.记下每行之前的标签:
environment=
CLOUD_INSTANCE_NAME=media-server-xx-xx-xx-xx,
CLOUD_APPLICATION=media-server,
CLOUD_APP_COMPONENT=none,
CLOUD_ZONE=a,
CLOUD_REGION=b,
CLOUD_PRIVATE_IP=none,
CLOUD_PUBLIC_IP=xx.xx.xx.xx,
CLOUD_PUBLIC_IPV6=xx.xx.xx.xx.xx.xx,
CLOUD_PROVIDER=c
Run Code Online (Sandbox Code Playgroud)
twi*_*clo 13
我知道这很旧,但我只是为此挣扎了几个小时,想帮助下一个人。
更新后不要忘记重新加载配置文件
supervisorctl reread
supervisorctl update
Run Code Online (Sandbox Code Playgroud)
如果从软件包安装程序安装supervisor,请检查您使用的Supervisor版本.截至2016年8月,您将获得3.0b2.如果是这种情况,您将需要更新版本的主管.你可以通过手动安装supervisor或使用Python的pip来获得它.确保满足所有依赖项以及upstart设置,以便supervisord作为服务工作并在系统引导时启动.
| 归档时间: |
|
| 查看次数: |
63512 次 |
| 最近记录: |