mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
657 B
TypeScript
27 lines
657 B
TypeScript
import type { PureContext, PureServiceSchema } from 'tailchat-server-sdk';
|
|
|
|
/**
|
|
* 增加一个action
|
|
* 用于返回当前节点的健康信息
|
|
*/
|
|
export const TcHealth = (): Partial<PureServiceSchema> => {
|
|
return {
|
|
actions: {
|
|
async health(ctx: PureContext) {
|
|
const status = ctx.broker.getHealthStatus();
|
|
|
|
const services: any[] = await ctx.call('$node.services');
|
|
|
|
return {
|
|
nodeID: this.broker.nodeID,
|
|
cpu: status.cpu,
|
|
memory: status.mem,
|
|
services: services
|
|
.filter((s) => s.available === true)
|
|
.map((s) => s.fullName),
|
|
};
|
|
},
|
|
},
|
|
};
|
|
};
|