@arcblock/pm2-prom-module 2.6.7 → 2.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/pm2.js +10 -2
- package/package.json +1 -1
- package/utils/domain.js +6 -6
package/core/pm2.js
CHANGED
|
@@ -163,6 +163,9 @@ const detectActiveApps = () => {
|
|
|
163
163
|
if (stats && Object.keys(stats).length) {
|
|
164
164
|
for (const [pid, stat] of Object.entries(stats)) {
|
|
165
165
|
const pidId = Number(pid);
|
|
166
|
+
if (!stat) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
166
169
|
if (pidId && pidsMonit[pidId]) {
|
|
167
170
|
pidsMonit[pidId].cpu = Math.round(stat.cpu * 10) / 10;
|
|
168
171
|
pidsMonit[pidId].memory = stat.memory;
|
|
@@ -226,13 +229,18 @@ const detectActiveApps = () => {
|
|
|
226
229
|
urls: yield (0, domain_1.getAppDomainList)(app.appUrl),
|
|
227
230
|
};
|
|
228
231
|
});
|
|
229
|
-
}), { concurrency: 8 })
|
|
232
|
+
}), { concurrency: 8 })
|
|
233
|
+
.then((apps) => {
|
|
230
234
|
for (const app of apps) {
|
|
235
|
+
if (!app.urls || !Array.isArray(app.urls)) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
231
238
|
for (const url of app.urls) {
|
|
232
239
|
metrics_1.metricAppDomainList === null || metrics_1.metricAppDomainList === void 0 ? void 0 : metrics_1.metricAppDomainList.set({ appName: app.appName, domain: url, appPid: app.appPid }, app.urls.length);
|
|
233
240
|
}
|
|
234
241
|
}
|
|
235
|
-
})
|
|
242
|
+
})
|
|
243
|
+
.catch((error) => console.error(error));
|
|
236
244
|
});
|
|
237
245
|
};
|
|
238
246
|
const startPm2Connect = (conf) => {
|
package/package.json
CHANGED
package/utils/domain.js
CHANGED
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getAppDomainList = getAppDomainList;
|
|
16
16
|
const is_url_1 = __importDefault(require("is-url"));
|
|
17
|
-
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
18
17
|
const ufo_1 = require("ufo");
|
|
19
18
|
const keyv_1 = __importDefault(require("keyv"));
|
|
20
19
|
const sqlite_1 = __importDefault(require("@keyv/sqlite"));
|
|
@@ -38,15 +37,16 @@ function getAppDomainList(url) {
|
|
|
38
37
|
if (!(0, is_url_1.default)(url)) {
|
|
39
38
|
return [url];
|
|
40
39
|
}
|
|
41
|
-
if (yield appDomainListCache.
|
|
42
|
-
return yield appDomainListCache.get(url);
|
|
40
|
+
if (yield appDomainListCache.get(url)) {
|
|
41
|
+
return (yield appDomainListCache.get(url));
|
|
43
42
|
}
|
|
44
43
|
const response = yield fetch((0, ufo_1.joinURL)(url, '__blocklet__.js?type=json'));
|
|
45
|
-
const domainAliases = (
|
|
46
|
-
if (
|
|
44
|
+
const domainAliases = (_a = (yield response.json())) === null || _a === void 0 ? void 0 : _a.domainAliases;
|
|
45
|
+
if (Array.isArray(domainAliases) && domainAliases.length) {
|
|
47
46
|
yield appDomainListCache.set(url, domainAliases);
|
|
47
|
+
return domainAliases;
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return [url];
|
|
50
50
|
}
|
|
51
51
|
catch (error) {
|
|
52
52
|
console.error(error);
|