主管不使用/etc/environment [英] Supervisor not using /etc/environment

查看:110
本文介绍了主管不使用/etc/environment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP脚本,该脚本使用getenv打印在/etc/environment中设置的环境变量.

I have an script in PHP that prints an environment variable set in /etc/environment with getenv.

当我手动执行它时,它可以正常工作,但是当主管执行时,它不起作用.

It works fine when I execute it manually, but when is executed by supervisor, it doesn't work.

我不想将此环境变量手动放在超级用户conf文件中,我希望它正确读取/etc/environment.

I don't want to put manually this environment variable on supervisor conf file, I want it to read /etc/environment correctly.

有帮助吗?预先感谢

推荐答案

在主管配置文件文档中说: supervisord配置文档 在部分环境中:

As it says in supervisord config files documentation: supervisord config documentation In the section environment:

请注意,子进程将继承用于启动"supervisord"的shell的环境变量,但此处覆盖的环境变量除外.

Note that the subprocess will inherit the environment variables of the shell used to start "supervisord" except for the ones overridden here.

我认为您开始使用systemd进行监督. 在这种情况下,您可以检查您的supervisord.service,然后在服务"部分中添加:

I supose that you start supervisord using systemd. In that case you could check your supervisord.service and in the Service section add:

EnvironmentFile=/etc/environment

在经过监督的systemctl守护进程重载和systemctl重新启动后,我认为它应该可以工作

After doing a systemctl daemon-reload and systemctl restart supervisord I supose it should work

您可以使用以下命令检查您的supervisord.service文件在哪里:

You could check where is your supervisord.service file using:

 systemctl status docker
 docker.service - Docker Application Container Engine
    Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)

我之所以使用docker,是因为我没有在开发机器中安装超级用户,但这是相同的

I have used docker because I have not installed supervisor in my dev machine, but it's the same

这篇关于主管不使用/etc/environment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆