UNPKG

speechflow

Version:

Speech Processing Flow Graph

60 lines 2.57 kB
"use strict"; /* ** SpeechFlow - Speech Processing Flow Graph ** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com> ** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only> */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeStatusManager = void 0; const cli_table3_1 = __importDefault(require("cli-table3")); const chalk_1 = __importDefault(require("chalk")); /* the node status manager */ class NodeStatusManager { cli; constructor(cli) { this.cli = cli; } /* gather and show status of all nodes */ async showNodeStatus(nodes, cfg, accessBus) { /* create CLI table */ const table = new cli_table3_1.default({ head: [ chalk_1.default.reset.bold("NODE"), chalk_1.default.reset.bold("PROPERTY"), chalk_1.default.reset.bold("VALUE") ], colWidths: [15, 15, 50 - (2 * 2 + 2 * 3)], style: { "padding-left": 1, "padding-right": 1, border: ["grey"], compact: true }, chars: { "left-mid": "", mid: "", "mid-mid": "", "right-mid": "" } }); /* iterate over all nodes... */ for (const name of Object.keys(nodes)) { /* instantiate node and query its status */ this.cli.log("info", `gathering status of node <${name}>`); const node = new nodes[name](name, cfg, {}, []); node._accessBus = accessBus; const status = await Promise.race([ node.status(), new Promise((resolve, reject) => setTimeout(() => reject(new Error("timeout")), 10 * 1000)) ]).catch((err) => { this.cli.log("warning", `[${node.id}]: failed to gather status of node <${node.id}>: ${err.message}`); return {}; }); /* render output as a table row */ if (Object.keys(status).length > 0) { let first = true; for (const key of Object.keys(status)) { table.push([first ? chalk_1.default.bold(name) : "", key, chalk_1.default.blue(status[key])]); first = false; } } } const output = table.toString(); process.stdout.write(output + "\n"); } } exports.NodeStatusManager = NodeStatusManager; //# sourceMappingURL=speechflow-main-status.js.map