In the spring-boot
module, you can find two classes to create files that are often
useful for process monitoring:
ApplicationPidFileWriter
creates a file containing the application PID (by default,
in the application directory with the file name, application.pid
).EmbeddedServerPortFileWriter
creates a file (or files) containing the ports of the
embedded server (by default, in the application directory with the file name
application.port
).By default, these writers are not activated, but you can enable them in one of the ways described in the next section.
In the META-INF/spring.factories
file, you can activate the listener(s) that writes a
PID file, as shown in the following example:
org.springframework.context.ApplicationListener=\ org.springframework.boot.system.ApplicationPidFileWriter,\ org.springframework.boot.system.EmbeddedServerPortFileWriter