我们有一个作为init.d服务运行的spring boot(版本1.3.3)应用程序。按照Spring Boot文档中有关部署here的说明进行配置。
我们使用“ .conf”文件在应用程序范围内定义RUN_ARGS,JVM参数和环境变量。
我们的应用程序功能没有问题,但是当我们启动服务(服务myapp start)时,它会创建一个名为“ LOGS_PATH_IS_UNDEFINED”的文件夹,并开始在其中登录。几行后,应用程序继续登录在“ .conf”文件中定义的环境变量中定义的文件夹中。
这是myapp.conf的内容:
LOGS_PATH="/usr/logs"
JAVA_HOME="/usr/java/jdk1.8.0_77"
JAVA_OPTS="-Xms256m -Xmx512m"
RUN_ARGS="--spring.profiles.active=staging --server.port=8090"
这是“ LOGS_PATH_IS_UNDEFINED”中的日志内容(无明智信息):
2018-10-08 09:43:42,549 INFO [main] Application:? : Starting Application v1.0 on server with PID xxxx (/opt/myapp/myapp.jar started by server in /opt/myapp)
2018-10-08 09:43:42,552 INFO [main] Application:? : The following profiles are active: staging
2018-10-08 09:43:51,106 INFO [localhost-startStop-1] WebConfigurer:? : Web application configuration, using profiles: [staging]
2018-10-08 09:43:51,133 INFO [localhost-startStop-1] WebConfigurer:? : Web application fully configured
2018-10-08 09:43:59,435 INFO [localhost-startStop-1] Application:? : Running with Spring profile(s) : [staging]
2018-10-08 09:44:01,215 INFO [main] ThymeleafConfiguration:? : loading non-reloadable mail messages resources
2018-10-08 09:44:14,223 INFO [main] Application:? : Started Application in 33.926 seconds (JVM running for 35.172)
2018-10-08 09:44:14,223 INFO [main] Application:? : Access URLs:
----------------------------------------------------------
Local: http://127.0.0.1:8090
External: http://127.0.1.1:8090
----------------------------------------------------------
2018-10-08 09:44:27,844 INFO [http-nio-8090-exec-1] CustomPersistentRememberMeServices:? : presentedToken=xxxxx / tokenValue=xxxxx
DevOps不知道为什么,他们要求我们对其进行修复。
我们在命令行中以可执行jar的形式运行应用程序时,没有此问题。
我们使用Logback进行日志记录。
先谢谢您的帮助!
最佳答案
我们解决了!
服务器中未设置环境变量。在“ .conf”中LOGS_PATH =“ / usr / logs”行之前的简单“导出”解决了该问题。