unable to use environment variable
See original GitHub issueI’m trying to use an environment variable JAVA_HOME in service.xml config. Somehow it gets not replaced. Is this the right way to work with env variables? As soon as I replace %JAVA_HOME% in service.xml with a jdk folder it works.
<id>tie-config-server</id>
<name>Configuration Server</name>
<description>Distributed Configuration - Properties Server</description>
<env name="JDK_HOME" value="%JAVA_HOME%" />
<executable>%JDK_HOME%/bin/java</executable>
<arguments>-Xrs -Xmx256m -jar ie-config-server.jar --spring.config.location=./properties/config-server.yml</arguments>
<startmode>Manual</startmode>
<log mode="roll-by-time">
<pattern>yyyyMMdd</pattern>
</log>
<logpath>%BASE%/logs</logpath>
<onfailure action="restart" delay="30 sec"/>
</service>```
Setting env variable , install and start Commands
D:\admin-bundle> set JAVA_HOME=D:\Oracle\java\jdk1.8.0_144
D:\admin-bundle> ie-config-server install
D:\admin-bundle>net start tie-config-server The iengine - Configuration Server service is starting. The iengine - Configuration Server service could not be started.
Log output:
2017-07-30 22:17:35,433 DEBUG - Starting ServiceWrapper in the CLI mode 2017-07-30 22:17:35,761 INFO - Installing the service with id ‘tie-config-server’ 2017-07-30 22:17:35,854 DEBUG - Completed. Exit code is 0 2017-07-30 22:17:39,505 INFO - Starting ServiceWrapper in the service mode 2017-07-30 22:17:39,551 INFO - Starting %JAVA_HOME%/bin/java -Xrs -Xmx256m -jar ie-config-server.jar --spring.config.location=./properties/config-server.yml 2017-07-30 22:17:39,567 INFO - Starting %JAVA_HOME%/bin/java -Xrs -Xmx256m -jar ie-config-server.jar --spring.config.location=./properties/config-server.yml 2017-07-30 22:17:39,583 DEBUG - Completed. Exit code is 0
regards & thanks for help
cyrill
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
This seems like a bug, unless I’m doing something incorrectly? The docs currently say:
“Configuration XML files can include environment variable expansions of the form %Name%. Such occurrences, if found, will be automatically replaced by the actual values of the variables. If an undefined environment variable is referenced, no substitution occurs.”
If we’re not able to use environment variables, what is the env for? Would be great to be able to use them as otherwise need to get a user to ensure Java is in the system path, rather than getting it from something else.
so, I’ve just been doing this
and in my bat file I can do things like
I havent tried with env vars, but if winsw copies the environment, at least the bat file will do the expansion.