mira-app-server
Version:
Mira Server - standalone server application using mira-app-core
51 lines • 1.73 kB
JavaScript
;
/**
* 系统模块命令
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerSystem = registerSystem;
const client_1 = require("../client");
const format_1 = require("../format");
function registerSystem(program) {
const system = program.command('system').description('系统信息');
system
.command('health')
.description('获取服务器健康状态')
.action(async () => {
try {
const { client } = (0, client_1.getAnonymousClient)();
const health = await client.system().getHealth();
(0, format_1.output)(health, () => (0, format_1.formatKeyValue)(health));
}
catch (error) {
(0, format_1.fatal)(error);
}
});
system
.command('info')
.description('获取服务器版本与运行环境信息')
.action(async () => {
try {
const { client } = (0, client_1.getClient)(false);
const info = await client.system().getSystemInfo();
(0, format_1.output)(info, () => (0, format_1.formatKeyValue)(info));
}
catch (error) {
(0, format_1.fatal)(error);
}
});
system
.command('uptime')
.description('获取服务器运行时间(可读格式)')
.action(async () => {
try {
const { client } = (0, client_1.getClient)(false);
const formatted = await client.system().getUptimeFormatted();
(0, format_1.output)({ uptime: formatted }, () => `运行时间: ${formatted}`);
}
catch (error) {
(0, format_1.fatal)(error);
}
});
}
//# sourceMappingURL=system.js.map