badmfck-api-server 4.1.27 → 4.1.29
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/dist/apiServer/APIService.d.ts +5 -0
- package/dist/apiServer/APIService.js +8 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +148 -0
- package/dist/apiServer/deployment/ConfigService.js +229 -0
- package/dist/apiServer/deployment/Deployer.d.ts +8 -0
- package/dist/apiServer/deployment/Deployer.js +55 -0
- package/dist/apiServer/deployment/DeployerService.d.ts +109 -0
- package/dist/apiServer/deployment/DeployerService.js +543 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +2 -0
- package/dist/apiServer/deployment/NginxHelper.js +37 -0
- package/dist/apiServer/deployment/Notifier.d.ts +16 -0
- package/dist/apiServer/deployment/Notifier.js +59 -0
- package/dist/apiServer/deployment/Watchdog.d.ts +14 -0
- package/dist/apiServer/deployment/Watchdog.js +61 -0
- package/dist/apiServer/external/MicroserviceClient.js +4 -4
- package/dist/apiServer/monitor/index.html +59 -56
- package/dist/apiServer/routes/Liveness.js +1 -1
- package/dist/apiServer/routes/Readiness.d.ts +1 -1
- package/dist/apiServer/routes/Readiness.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Watchdog = void 0;
|
|
4
|
+
const __1 = require("../..");
|
|
5
|
+
const BaseService_1 = require("../BaseService");
|
|
6
|
+
const ConfigService_1 = require("./ConfigService");
|
|
7
|
+
class Watchdog extends BaseService_1.BaseService {
|
|
8
|
+
config = new Map();
|
|
9
|
+
lastStatuses = new Map();
|
|
10
|
+
notifier = null;
|
|
11
|
+
constructor(notifier) {
|
|
12
|
+
super("Watchdog");
|
|
13
|
+
this.notifier = notifier || null;
|
|
14
|
+
}
|
|
15
|
+
applicationReady() {
|
|
16
|
+
this.setup();
|
|
17
|
+
ConfigService_1.S_CONFIG_UPDATED.subscribe(async () => { this.config = await ConfigService_1.REQ_DEPLOYMENT_CONFIG.request(); });
|
|
18
|
+
}
|
|
19
|
+
async setup() {
|
|
20
|
+
this.config = await ConfigService_1.REQ_DEPLOYMENT_CONFIG.request();
|
|
21
|
+
setInterval(() => {
|
|
22
|
+
for (let i of this.config) {
|
|
23
|
+
if (i[1].readiness) {
|
|
24
|
+
this.checkReadiness(i[1]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, 10000);
|
|
28
|
+
}
|
|
29
|
+
async checkReadiness(config) {
|
|
30
|
+
if (!config.readiness)
|
|
31
|
+
return;
|
|
32
|
+
const resp = await __1.Http.get(config.readiness);
|
|
33
|
+
if (resp.ok) {
|
|
34
|
+
this.statusPassed(config);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.statusFailed(config);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
statusPassed(config) {
|
|
41
|
+
if (this.lastStatuses.get(config.name) === false) {
|
|
42
|
+
if (config.email && config.email.length > 0) {
|
|
43
|
+
for (let email of config.email) {
|
|
44
|
+
this.notifier?.notifyEmailStatus(email, "readiness-ok", config.name, "watchdog");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.lastStatuses.set(config.name, true);
|
|
49
|
+
}
|
|
50
|
+
statusFailed(config) {
|
|
51
|
+
if (this.lastStatuses.get(config.name) !== false) {
|
|
52
|
+
if (config.email && config.email.length > 0) {
|
|
53
|
+
for (let email of config.email) {
|
|
54
|
+
this.notifier?.notifyEmailStatus(email, "readiness-error", config.name, "watchdog");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.lastStatuses.set(config.name, false);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Watchdog = Watchdog;
|
|
@@ -90,14 +90,14 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
90
90
|
await TimeframeService_1.TimeframeService.wait(attemptTimeout * attempt);
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, details: "Network connection lost after multiple retries, attempts: " + attempt };
|
|
93
|
+
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, stack: [this.options.host, req], details: "Network connection lost after multiple retries, attempts: " + attempt };
|
|
94
94
|
}
|
|
95
95
|
if (!resp.ok) {
|
|
96
96
|
console.log(`Microservice call error response:`, resp);
|
|
97
97
|
const remoteError = resp.error?.error;
|
|
98
98
|
if (DefaultErrors_1.ErrorUtils.isError(remoteError))
|
|
99
99
|
return remoteError;
|
|
100
|
-
return { ...DefaultErrors_1.default.BAD_REQUEST, stack: [resp.error], details: resp.details };
|
|
100
|
+
return { ...DefaultErrors_1.default.BAD_REQUEST, stack: [this.options.host, req, resp.error], details: resp.details };
|
|
101
101
|
}
|
|
102
102
|
const body = resp.data;
|
|
103
103
|
const isAccepted = body?.error?.code === DefaultErrors_1.default.ACCEPTED.code || body?.code === DefaultErrors_1.default.ACCEPTED.code;
|
|
@@ -106,14 +106,14 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
106
106
|
await TimeframeService_1.TimeframeService.wait(attemptTimeout * attempt);
|
|
107
107
|
continue;
|
|
108
108
|
}
|
|
109
|
-
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, details: "Microservice processing timeout, attempts: " + attempt };
|
|
109
|
+
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, stack: [this.options.host, req], details: "Microservice processing timeout, attempts: " + attempt };
|
|
110
110
|
}
|
|
111
111
|
if (body && typeof body === "object") {
|
|
112
112
|
return "error" in body ? body.error : (body.data ?? null);
|
|
113
113
|
}
|
|
114
114
|
return body ?? null;
|
|
115
115
|
}
|
|
116
|
-
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, details: "Unknown polling error" };
|
|
116
|
+
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, stack: [this.options.host, req], details: "Unknown polling error" };
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
exports.MicroserviceClient = MicroserviceClient;
|