60. Process Monitoring

spring-boot模块中,您可以找到两个类来创建通常对过程监视有用的文件:

默认情况下,不会激活这些编写器,但是您可以启用:

60.1 扩展配置

META-INF/spring.factories文件中,可以激活写入 PID 文件的侦听器,如以下示例所示:

org.springframework.context.ApplicationListener=\
org.springframework.boot.context.ApplicationPidFileWriter,\
org.springframework.boot.web.context.WebServerPortFileWriter

60.2 Programmatically

您还可以通过调用SpringApplication.addListeners(…)方法并传递适当的Writer对象来激活侦听器。此方法还允许您自定义Writer构造函数中的文件名和路径。

上一章 首页 下一章