feat(center): enhance health check with DB readiness
This commit is contained in:
@@ -1,9 +1,25 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get, ServiceUnavailableException } from '@nestjs/common';
|
||||||
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
@Controller('healthz')
|
@Controller('healthz')
|
||||||
export class HealthController {
|
export class HealthController {
|
||||||
|
constructor(private readonly dataSource: DataSource) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
get() {
|
async get() {
|
||||||
return { ok: true, service: 'center' };
|
try {
|
||||||
|
await this.dataSource.query('SELECT 1');
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
service: 'center',
|
||||||
|
database: 'ready',
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
throw new ServiceUnavailableException({
|
||||||
|
ok: false,
|
||||||
|
service: 'center',
|
||||||
|
database: 'not_ready',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
### 1.3 Center 运维能力
|
### 1.3 Center 运维能力
|
||||||
- [x] 审计日志(auth/node 关键操作)
|
- [x] 审计日志(auth/node 关键操作)
|
||||||
- [ ] 健康检查深化(DB ready)
|
- [x] 健康检查深化(DB ready)
|
||||||
- [x] 配置校验(启动时必填项检查)
|
- [x] 配置校验(启动时必填项检查)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user