启动时可选记录pid

pull/735/head
Zheng Jie 2022-03-07 14:12:58 +08:00
parent e06ec08400
commit b9aca9366d
2 changed files with 8 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.utils.SpringContextHolder; import me.zhengjie.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -43,7 +44,11 @@ import org.springframework.web.bind.annotation.RestController;
public class AppRun { public class AppRun {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(AppRun.class, args); SpringApplication springApplication = new SpringApplication(AppRun.class);
// 监控应用的PID启动时可指定PID路径--spring.pid.file=/home/eladmin/app.pid
// 或者在 application.yml 添加文件路径,方便 killkill `cat /home/eladmin/app.pid`
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
} }
@Bean @Bean

View File

@ -12,6 +12,8 @@ spring:
redis: redis:
repositories: repositories:
enabled: false enabled: false
# pid:
# file: /自行指定位置/eladmin.pid
#配置 Jpa #配置 Jpa
jpa: jpa: