Open ochinchina opened 6 years ago
Isn't that what config files are for?
Have you developed something to fix this issue @ochinchina ?
If I try to execute this command with the supervisord running within a pod on k8s, then I don't see that the parameter is passed to the java command launched
export JAVA_OPTIONS=-Dspring.profiles.active=openshift
/var/lib/supervisord/bin/supervisord ctl start run-java
Log of the java application
Starting the Java application using /opt/run-java/run-java.sh ...
--
| exec java -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseParallelOldGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/my-spring-boot-1.0.jar
| Listening for transport dt_socket at address: 5005
| time="2018-08-24T13:56:07Z" level=debug msg="wait program exit" program=run-java
| I> No access restrictor found, access to any MBean is allowed
| Jolokia: Agent started with URL https://172.17.0.6:8778/jolokia/
| . ____ _ __ _ _
| /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
| ( ( )\___ \| '_ \| '_\| \| '_ \/ _` \| \ \ \ \
| \\/ ___)\| \|_)\| \| \| \| \| \|\| (_\| \| ) ) ) )
| ' \|____\| .__\|_\| \|_\|_\| \|_\__, \| / / / /
| =========\|_\|==============\|___/=/_/_/_/
| :: Spring Boot :: (v1.5.15.RELEASE)
| 2018-08-24 13:56:08.203 INFO 909 --- [ main] com.example.demo.CrudApplication : Starting CrudApplication on my-spring-boot-1-w2g28 with PID 909 (/deployments/my-spring-boot-1.0.jar started by jboss in /deployments)
and spring report that no profile other then default has been defined (= that confirms that the env var wasn't set)
| 2018-08-24 13:56:08.207 INFO 909 --- [ main] com.example.demo.CrudApplication : No active profile set, falling back to default profiles: default
@cmoulliard please put your environment "JAVA_OPTIONS=-Dspring.profiles.active=openshift" to the supervisord configuration file( in program:x section and the key is "environment").
The command "/var/lib/supervisord/bin/supervisord ctl start run-java" will not pass the environment variable to the "supervisord". The "supervisord ctl start" makes a XML RPC call to the supervisord and ask the supervisord start the program.
Currently, to pass an environment variable to supervisord process we need to "export ENV_NAME=value". This will cause inconvenience sometime and also will be required to set a lot of environment variables.
We want to put all the related environment variables to a single file and the supervisor load this environment file and set it for the program.