53. Process monitoring

In Spring Boot Actuator you can find a couple of classes to create files that are useful for process monitoring:

These writers are not activated by default, but you can enable them in one of the ways described below.

53.1 Extend configuration

In META-INF/spring.factories file you can activate the listener(s) that writes a PID file. Example:

org.springframework.context.ApplicationListener=\
org.springframework.boot.system.ApplicationPidFileWriter,\
org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter

53.2 Programmatically

You can also activate a listener by invoking the SpringApplication.addListeners(…​) method and passing the appropriate Writer object. This method also allows you to customize the file name and path via the Writer constructor.