Skip to content

Commit

Permalink
启动时可选记录pid
Browse files Browse the repository at this point in the history
  • Loading branch information
elunez committed Mar 7, 2022
1 parent e06ec08 commit b9aca93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eladmin-system/src/main/java/me/zhengjie/AppRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import me.zhengjie.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
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.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
Expand All @@ -43,7 +44,11 @@
public class AppRun {

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 添加文件路径,方便 kill,kill `cat /home/eladmin/app.pid`
springApplication.addListeners(new ApplicationPidFileWriter());
springApplication.run(args);
}

@Bean
Expand Down
2 changes: 2 additions & 0 deletions eladmin-system/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spring:
redis:
repositories:
enabled: false
# pid:
# file: /自行指定位置/eladmin.pid

#配置 Jpa
jpa:
Expand Down

0 comments on commit b9aca93

Please sign in to comment.