phpenvironmentsupervisordgetenv

Supervisor not using /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.

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


Solution

  • 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