Supervisor not using /etc/environment

烈酒焚心 提交于 2020-06-17 05:36:13

问题


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.

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

Any help? Thanks in advance


回答1:


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

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

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

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

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)

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




回答2:


getenv gets the value of an environment variable, it doesn't read values from a file. If the environment variable isn't set for your supervisor's session then how can getenv retrieve the value?

From your session, enter the 'set' command. What is the output of that command? From your supervisor's session, enter the 'set' command? What is the output?

Are you certain that the environment variables for your session are getting set via /etc/environment?



来源:https://stackoverflow.com/questions/47083582/supervisor-not-using-etc-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!