From part V. Spring loading drive: Documentation for ready-made parts :
In the spring-boot module, you can find two classes for creating files, which are often useful for monitoring processes:
- ApplicationPidFileWriter creates a file containing the application PID (by default, in the application directory with the file name application.pid).
- WebServerPortFileWriter creates a file (or files) containing the ports of a running web server (by default, in the application directory with the file name application.port).
By default, these writers are not activated, but you can enable:
- Expanding Configuration
- Section 60.2, "Software"
Here is part of the 60.1 configuration extension:
In the META-INF / spring.factories file, you can activate listeners that write the PID file, as shown in the following example:
org.springframework.context.ApplicationListener=\ org.springframework.boot.context.ApplicationPidFileWriter,\ org.springframework.boot.web.context.WebServerPortFileWriter
This allows you to display both pid and port at startup.
So the idea is quite simple: in the src/main/resources/META-INF
folder of your spring.factories
boot application, if it does not exist, create a spring.factories
file with the previous contents to include both (pid or port) or with The following is to enable only PID output:
org.springframework.context.ApplicationListener=org.springframework.boot.context.ApplicationPidFileWriter
source share