healthz
Official sources are open to Staxis GitLab group members:
how to join and view the code.
Repository: healthz development
Versions: tags
and releases
Description
healthz mounts operational endpoints for health and readiness checks on serverApp. It can also expose a token-protected shutdown endpoint when explicitly enabled. An optional isolated HTTP listener provides emergency diagnostics when the serverApp facade cannot be obtained.
The general /healthz and /readyz probes currently use the same listener-address check. Per-layer probes report the Core metadata's processed flag. These are operational signals, not application-specific database, dependency, or business-logic tests.
Read before flight
-
We suggest exposing only the diagnostic paths needed by your monitoring system. Layer-list responses reveal available labels; the current routing does not apply healthzList consistently to every list alias. Restrict those paths at the proxy or network boundary when they should remain private.
-
We suggest leaving shutdown disabled unless required. When enabled, protect it as an administrative operation and prefer the x-admin-token header over a query token that can appear in URL logs. Never commit a real shutdown secret.
-
We suggest keeping isolated diagnostics disabled during normal shared HTTP operation. Its default loopback address limits exposure; changing the host is an explicit deployment decision requiring suitable network access controls.
-
We suggest testing probes through the complete HTTP chain. Earlier middleware can intercept a request; a processed layer or an HTTP 202 shutdown response does not establish that its application work or resource cleanup has completed.
Files Map
| File | Purpose |
|---|---|
| manifest.json | Declares the healthz label and runtime typology |
| configs.js | Defines probe, layer-list, isolated-listener, and shutdown options |
| main.js | Mounts the operational endpoints and optional shutdown flow |
| .fomap | File map used by the Manager installation flow |
| README.md | Original configuration and usage reference |
Requirements and Installation
Install through the Manager:
manager -> install -> healthz
In the normal stack, place healthz after serverApp, before terminal fallback handlers such as httpKindness. Requests use the shared httpListener; the supplied serverApp and httpListener manifests already permit the healthz caller label. Their runtime availability and access determine the general probe result.
The pack has no additional npm dependency. Prepare the normal Vault material through First setup. Both manifest.label and manifest.typology are healthz, with KEY:HEALTHZ as the typology key. Only the optional shutdown feature requires graceful. Without serverApp, diagnostics require the isolated mode to be explicitly enabled.
Configuration
All options belong to config.serveropt. Merge the supplied defaults into config.js, preserving the project's other server options:
// config.js -> config (merge into the exported object)
serveropt: {
healthzEnable: true,
healthzList: false,
healthzIsolated: {
enable: false,
host: '127.0.0.1',
port: 3099
},
healthzShutdown: {
enable: false,
alias: 'shutdown',
apiKey: false
}
}
config.serveropt.healthzEnable: false disables mounting the endpoints at startup. healthzIsolated and healthzShutdown can each be false instead of an object; when an object is used, only enable: true activates that feature. The healthzList option is intended to unlock layer enumeration. Its current routing behavior is detailed below, so do not use false as an access-control guarantee.
How to Use
Let the layer mount its routes during boot, then query the running application. The request paths below use the normal shared HTTP listener:
GET /healthz
GET /healthz/httpListener
GET /readyz
GET /readyz/serverApp
The probe middleware accepts GET and HEAD. Other methods and unrelated paths continue to later middleware. Query strings do not change the probe target; repeated slashes and a trailing slash are normalized.
| Path | Current check | Response |
|---|---|---|
| /healthz or /readyz | Whether the authorized httpListener instance exposes a non-empty address() | 200 ok, otherwise 503 fail |
| /healthz/<layer> or /readyz/<layer> | Whether the matching Core layer metadata has processed === true | 200 ok, 500 fail, or 404 unknown |
| More than one segment after the probe name | Invalid per-layer target | 400 bad request |
A layer target is resolved case-insensitively against manifest.label or manifest.typology. For example, /readyz/serverApp checks that layer's processed metadata; it does not fetch its private runtime state. The general probes return 503 if listener access is unavailable, even when their own route handler is reachable.
Layer Lists
GET /healthz/list
GET /healthz/*
GET /readyz/list
GET /readyz/*
List responses use HTTP 200 and a JSON array of available layer paths, not per-layer health details. For example:
["/serverApp", "/httpListener"]
In the current implementation, only /healthz/list checks config.serveropt.healthzList === true. /healthz/*, /readyz/list, and /readyz/* return the list regardless of that flag. Apply an external route restriction when enumeration must not be public.
Optional Shutdown Endpoint
Shutdown is disabled by default. To enable it, load graceful before healthz, configure its ordered target list, and add the requesting pack label healthz to graceful's manifest.permits, preserving its existing entries:
// graceful/manifest.json: permits field
"permits": ["graceful", "sysrestart", "healthz"]
Then enable the feature under config.serveropt. This example keeps the secret out of config.js and reads it from the host's SHUTDOWN_KEY environment variable:
// config.js -> config (merge into the exported object)
serveropt: {
healthzShutdown: {
enable: true,
alias: 'shutdown',
apiKey: false
}
}
The current secret source is config.serveropt.healthzShutdown.apiKey, with SHUTDOWN_KEY as its environment fallback. This is a separate administrative secret, not a Vault access token. A dedicated Vault credential awaits the planned multi-key support. If no non-empty secret is available, the endpoint is not mounted. The layer logs a specific warning when graceful is loaded but denies access to healthz.
POST /shutdown HTTP/1.1
x-admin-token: YOUR_PRIVATE_TOKEN
The README's query form is also accepted:
POST /shutdown?token=YOUR_PRIVATE_TOKEN
The alias selects the exact POST path. An invalid or missing token returns 401 unauthorized. An authorized request receives 202 shutting-down... before graceful.close() runs; its result is reported through logs rather than returned in that HTTP response. This requests the configured detach sequence, not a Node.js process exit or restart. See sysrestart for scheduled restarts.
Isolated Emergency Diagnostics
Keep config.serveropt.healthzIsolated disabled for ordinary shared HTTP operation. With enable: true, healthz first tries serverApp and creates a minimal native HTTP listener only when that facade cannot be obtained. This is not an automatic fallback for every later application or listener failure.
// config.js -> config (merge into the exported object)
serveropt: {
healthzIsolated: {
enable: true,
host: '127.0.0.1',
port: 3099
}
}
The isolated port must be an integer from 1 to 65535. On this emergency listener, /healthz and /readyz return HTTP 503 with a JSON degraded-state report. For an unavailable or invalid serverApp facade, the response is:
{
"live": true,
"ready": false,
"degraded": true,
"reason": "serverApp facade is unavailable or invalid"
}
The reason can instead describe the failure encountered while obtaining serverApp. The isolated listener does not mount the shutdown endpoint and is closed on detach. Binding beyond loopback exposes diagnostics and must be protected at the network level.
Published Assets and Lifecycle
The active bundle exposes mountHealthz, mountReadyz, and mountShutdown functions used during attachment. The routes are already registered; consumers should not call these mounting functions again. When healthzEnable is false at initial startup, the published assets are empty.
Detach closes an isolated listener when present and publishes shutdown: false, healthz: false, and readyz: false. Shared route handlers consult the layer's runtime status and pass requests onwards while it is inactive.
Documentation
This page is the HTML adaptation of the pack's README.md, with configuration, response semantics, and current list-routing behavior checked against the implementation. Complete Staxis onboarding to request GitLab access to the official sources.