WatchdogApp
Watchdog Application Configuration
The N2SVCD Watchdog Application is a special case application.
- A
WatchdogAppwill always be created, even if not present inapplications. - The
WatchdogAppalways runs within then2svcdprocess, it never forks.
Note that the WatchdogApp is quite distinct from the ManageApp:
- The
WatchdogAppis mandatory, whileManageAppis entirely optional. - The
WatchdogAppis never forked, butManageAppmay be forked. - The
WatchdogAppis responsible for Shutdown on Signals and Heartbeats. - The
ManageAppsupports query, trace, and management of applications and instances.
The following configuration is used to create a Watchdog Application instance. If you omit this section, a default Watchdog Application will be created.
<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
...
<applications>
...
<application name="Watchdog" module="WatchdogApp">
<include><lib>../apps/watchdog/lib</lib></include>
<parameters>
<parameter name="shutdown_notice_secs" value="4"/>
<parameter name="termination_notice_ms" value="500"/>
<parameter name="heartbeat_interval_secs" value="120"/>
<parameter name="heartbeat_response_ms" value="900"/>
</parameters>
<config>
<heartbeats>
<heartbeat app_name="App1" heartbeat_interval_secs="300" heartbeat_response_ms="300000"/>
</heartbeats>
</config>
</application>
...
</application>
...
</n2svcd>
Configuration Details
The application element attributes for a Watchdog Application instance may include the below.
For details of the various parameter types used, refer to Common Configuration.
| Parameter Name | Type | XML Type | Description |
|---|---|---|---|
| See: Common Application configuration | |||
module
|
String | Attribute |
[Required] WatchdogApp
|
include.lib
|
String | Attribute |
[Required] ../apps/watchdog/lib
|
parameters
|
Array | Element |
[Required] As per Common Configuration Application parameters.
|
"edr_enabled"
|
- | - | This value is ignored; the Watchdog Application does not support writing EDRs. |
"shutdown_notice_secs"
|
Integer (1..60) |
Attribute |
Number of seconds from Shutdown Notice until actual Shutdown. (Default = 10)
|
"termination_notice_ms"
|
Integer (100..5000) |
Attribute |
Number of milliseconds from Shutdown until process Termination. (Default = 1000)
|
"heartbeat_interval_secs"
|
Integer (0..60) |
Attribute |
Number of seconds between application heartbeats. Set to 0 to disable heartbeats.(Default = 30)
|
"heartbeat_startup_secs"
|
Integer (1..60) |
Attribute |
Number of seconds after Watchdog startup to send initial application heartbeats.
Only applicable if heartbeat_interval_secs is greater than 0.(Default = 3)
|
"heartbeat_response_ms"
|
Integer (100..5000) |
Attribute |
Number of milliseconds before an application Heartbeat Response is considered overdue. (Default = 1000)
|
"overdue_to_terminate_secs"
|
Integer (0..60) |
Attribute |
When a heartbeat response is overdue, the watchdog immediately generates a warning message and then
begins checking to see if the application sub-process has died. If, after this number of
seconds, the overdue application sub-process has not died, then watchdog will actively terminate
the application sub-process using the TERM signal.(Default = 3)
|
"terminated_to_killed_secs"
|
Integer | Attribute |
After sending the TERM signal, the watching process will continue to monitor to check to see
if the application sub-process has died. If, after this number of seconds, the overdue application
sub-process has not died, then watchdog will actively kill the application subprocess using the
KILL signal, and then will wait indefinitely until the sub-process dies.(Default = 3)
|
"restart_retry_secs"
|
Integer | Attribute |
After the overdue application sub-process has died, then the watchdog process will immediately
restart a new application sub-process. If this restart fails, the watchdog process will repeatedly
attempt to restart the process each this number of seconds. Will be set to the maximum of 1
or the configured value.(Default = 30)
|
"application_availability_secs"
|
Integer (0..60) |
Attribute |
Number of seconds between reporting application availability. Set to 0 to disable checking. Note
that this is not affected by application heartbeats.(Default = 10)
|
Application-Specific Heartbeats
Individual applications may have explicit heartbeat configuration values set, overriding the
heartbeat_interval_secs, heartbeat_startup_secs, and heartbeat_response_ms parameters for that application only.
Application-specific heartbeats are configured in the heartbeats section of the extended configuration config block:
<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
...
<applications>
...
<application name="Watchdog" module="WatchdogApp">
...
<parameters>
...
</parameters>
<config>
<heartbeats>
<heartbeat app_name="App1" heartbeat_interval_secs="300" heartbeat_response_ms="300000"/>
</heartbeats>
</config>
</application>
...
</application>
...
</n2svcd>
The following parameters are supported for each heartbeat configured:
| Field | Type | Details |
|---|---|---|
app_name |
String | [Required] The configured application name that the heartbeat applies for. |
heartbeat_interval_secs |
Integer | The number of seconds between sending application heartbeats. (Default: 30) |
heartbeat_startup_secs |
Integer | The number of seconds before sending first heartbeat. (Default: 3) |
heartbeat_response_ms |
Integer | The number of milliseconds before an application heartbeat response is considered overdue. _(Default: 1000) |
Message Handling
In addition to the common Application management messages, the WatchdogApp uses the following messages:
- MANAGEMENT Messages (!MANAGEMENT-*-REQUEST outbound).