32 lines
1.4 KiB
Plaintext
32 lines
1.4 KiB
Plaintext
[[actuator.process-monitoring]]
|
|
== Process Monitoring
|
|
In the `spring-boot` module, you can find two classes to create files that are often useful for process monitoring:
|
|
|
|
* `ApplicationPidFileWriter` creates a file that contains the application PID (by default, in the application directory with a file name of `application.pid`).
|
|
* `WebServerPortFileWriter` creates a file (or files) that contain the ports of the running web server (by default, in the application directory with a file name of `application.port`).
|
|
|
|
By default, these writers are not activated, but you can enable them:
|
|
|
|
* <<actuator#actuator.process-monitoring.configuration,By Extending Configuration>>
|
|
* <<actuator#actuator.process-monitoring.programmatically>>
|
|
|
|
|
|
|
|
[[actuator.process-monitoring.configuration]]
|
|
=== Extending Configuration
|
|
In the `META-INF/spring.factories` file, you can activate the listener (or listeners) that writes a PID file:
|
|
|
|
[indent=0]
|
|
----
|
|
org.springframework.context.ApplicationListener=\
|
|
org.springframework.boot.context.ApplicationPidFileWriter,\
|
|
org.springframework.boot.web.context.WebServerPortFileWriter
|
|
----
|
|
|
|
|
|
|
|
[[actuator.process-monitoring.programmatically]]
|
|
=== Programmatically Enabling Process Monitoring
|
|
You can also activate a listener by invoking the `SpringApplication.addListeners(...)` method and passing the appropriate `Writer` object.
|
|
This method also lets you customize the file name and path in the `Writer` constructor.
|