# Liveliness Pinging

The Stream Cache Server has the optional capability to send periodic REST-style HTTP calls indicating the current liveliness state to a configurable server. A base URL must be specified in the application settings. After the application has started, it will then issue HTTP POST calls with a URL as follows: <base-url>/<id>?liveliness=<current-liveliness>. The POST calls will contain an empty body.

The values for liveliness include:

- ready: Issued after the server has performed all internal initialization and is ready to stream data

- ping: Issued at periodic intervals specified by `--liveliness-update-frequency`

- disconnect: Issued after the server has closed its websocket port and is about to shutdown

The capability can be used as follows:

1. Specify a unique ID with the `--id` setting: Example: `--id=7766-affg`

2. Specify a base URL to receive the liveliness calls with the `--liveliness-endpoint` setting. As an example: `--liveliness-endpoint=http://localhost:11082/server-status`

3. Specify a report frequency with `--liveliness-update-frequency`. Example: to send an update every five seconds, use `--liveliness-update-frequency=5.0`

4. Launch the Stream Cache Server application with those settings

5. Once the server has completed its internal initialization and is ready to stream data, it will issue a ready indication by issuing an empty HTTP POST to `http://localhost:11082/server-status/7766-affg?liveliness=ready`

6. Every 5.0 seconds after that, until the server is about to exit, it will issue an empty HTTP POST to `http://localhost:11082/server-status/7766-affg?liveliness=ping`

7. Finally, when the server is ready to exit, it will issue an empty HTTP POST to `http://localhost:11082/server-status/7766-affg?liveliness=disconnect`