UNPKG

pandora

Version:

A powerful and lightweight application manager for Node.js applications powered by TypeScript.

92 lines 3.87 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const GlobalConfigProcessor_1 = require("../universal/GlobalConfigProcessor"); const LoggerBroker_1 = require("../universal/LoggerBroker"); class DaemonIntrospection { constructor(daemon) { this.globalProperties = GlobalConfigProcessor_1.GlobalConfigProcessor.getInstance().getAllProperties(); this.daemon = daemon; } listApplication() { return __awaiter(this, void 0, void 0, function* () { const daemon = this.daemon; const keySet = Array.from(daemon.apps.keys()); const ret = []; for (const key of keySet) { const complex = daemon.apps.get(key); const introspection = yield complexToIntrospection(complex); ret.push(introspection); } return ret; }); } getApplictaionByName(appName) { return __awaiter(this, void 0, void 0, function* () { const daemon = this.daemon; const complex = daemon.apps.get(appName); if (!complex) { throw new Error(`Can\'t found an Application it named ${appName}`); } return complexToIntrospection(complex); }); } getLoadedGlobalConfigPaths() { return GlobalConfigProcessor_1.GlobalConfigProcessor.getInstance().loadedConfigPath; } getLoadedEndPointNames() { let loadedEndPoints = []; for (let endPointName in this.globalProperties['actuator']['endPoint']) { if (this.globalProperties['actuator']['endPoint'][endPointName].enabled) { loadedEndPoints.push(endPointName); } } return loadedEndPoints; } getLoadedReporterNames() { let loadedReporters = []; for (let reporterName in this.globalProperties['reporter']) { if (this.globalProperties['reporter'][reporterName].enabled) { loadedReporters.push(reporterName); } } return loadedReporters; } introspectDaemon() { return { versions: Object.assign({}, process.versions, { pandora: require('../../package.json').version }), cwd: process.cwd(), pid: process.pid, uptime: process.uptime(), loadedGlobalConfigPaths: this.getLoadedGlobalConfigPaths(), loadedEndPoints: this.getLoadedEndPointNames(), loadedReporters: this.getLoadedReporterNames(), }; } } exports.DaemonIntrospection = DaemonIntrospection; function complexToIntrospection(complex) { return __awaiter(this, void 0, void 0, function* () { return { state: complex.state, mode: complex.mode, appName: complex.name, appDir: complex.appDir, appId: complex.appId, pids: complex.pids, uptime: complex.uptime, startCount: complex.startCount, representation: complex.appRepresentation, complex: yield complex.getComplex(), stdoutLogPath: LoggerBroker_1.getAppLogPath(complex.name, 'nodejs_stdout') }; }); } //# sourceMappingURL=DaemonIntrospection.js.map