43. Process monitoring

In Spring Boot Actuator you can find ApplicationPidListener which creates file containing application PID (by default in application directory and file name is application.pid). It’s not activated by default, but you can do it in two simple ways described below.

43.1 Extend configuration

In META-INF/spring.factories file you have to activate the listener:

org.springframework.context.ApplicationListener=\
org.springframework.boot.actuate.system.ApplicationPidListener

43.2 Programmatically

You can also activate this listener by invoking SpringApplication.addListeners(...) method and passing ApplicationPidListener object. You can also customize file name and path through constructor.