I am using supervisorctl for running a program and environment variables to store the common variables.
For setting Environment Variable I am using /etc/environment. I have added the following as environment variable:
Foo=Bar Then I made sure the environment variable is set right by using the following command
echo $Foo > Bar This is a Sample Program Which I am trying to run using Supervisor:
echo $Foo while : do sleep 10s echo "I have completed" done When I run the program directly its working variable properly:
sh /home/data/trial.sh > Bar I have completed I have added Trial.conf in my /etc/supervisor/conf.d/ directory. This is my Trial.conf:
[program:Trial] command = sh /home/data/trial.sh When I run the program using supervisorctl
supervisor> start Trial Trial: started supervisor> fg Trial I have completed I found some solutions for setting the local environment variable for supervisorctl
I tried the following:
[supervisord] environment=Foo="%(ENV_Foo)s" But when I rebooted the supervisor and started the supervisor I got this error:
unix:///var/run/supervisor.sock no such file One behavior I noticed is that when I am using sudo Then I cannot access my environmental variables:
echo $Foo > Bar sudo echo $Foo > For that, I found a solution sudo -E su which will preserve $Foo for root.
Question: How can I make Supervisor access my local environmental variables?