Merge pull request #24817 from backstage/healthcheck-router
Healthcheck service
This commit is contained in:
@@ -28,6 +28,7 @@ import { coreServices } from '@backstage/backend-plugin-api';
|
||||
- [Permissions Service](./permissions.md) - Permission system integration for authorization of user actions.
|
||||
- [Plugin Metadata Service](./plugin-metadata.md) - Built-in service for accessing metadata about the current plugin.
|
||||
- [Root Config Service](./root-config.md) - Access to static configuration.
|
||||
- [Root Health Service](./root-health.md) - Health check endpoints for the backend.
|
||||
- [Root Http Router Service](./root-http-router.md) - HTTP route registration for root services.
|
||||
- [Root Lifecycle Service](./root-lifecycle.md) - Registration of backend startup and shutdown lifecycle hooks.
|
||||
- [Root Logger Service](./root-logger.md) - Root-level logging.
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
id: root-health
|
||||
title: Root Health Service
|
||||
sidebar_label: Health
|
||||
description: Documentation for the Health service
|
||||
---
|
||||
|
||||
The Root Health service provides some health check endpoints for the backend. By default, the `rootHttpRouter` exposes a `/.backstage/health/v1/readiness` and `/.backstage/health/v1/liveness` endpoints, which return a JSON object with the status of the backend services according the implementation of the Root Health Service.
|
||||
|
||||
## Configuring the service
|
||||
|
||||
The following example shows how you can override the root health service implementation.
|
||||
|
||||
```ts
|
||||
import { RootHealthService, coreServices } from '@backstage/backend-plugin-api';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
class MyRootHealthService implements RootHealthService {
|
||||
async getLiveness() {
|
||||
// provide your own implementation
|
||||
return { status: 200, payload: { status: 'ok' } };
|
||||
}
|
||||
|
||||
async getReadiness() {
|
||||
// provide your own implementation
|
||||
return { status: 200, payload: { status: 'ok' } };
|
||||
}
|
||||
}
|
||||
|
||||
backend.add(
|
||||
createServiceFactory({
|
||||
service: coreServices.rootHealth,
|
||||
deps: {},
|
||||
async factory({}) {
|
||||
return new MyRootHealthService();
|
||||
},
|
||||
}),
|
||||
);
|
||||
```
|
||||
Reference in New Issue
Block a user