@nsshunt/stsappframework 3.1.234 → 3.1.235
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/.github/workflows/npm-publish.yml +18 -29
- package/build.sh +12 -6
- package/eslint.config.mjs +7 -0
- package/package.json +11 -14
- package/.eslintrc.json +0 -27
- package/babel.config.json +0 -6
- package/dist/commonTypes.js +0 -69
- package/dist/commonTypes.js.map +0 -1
- package/dist/controller/stscontrollerbase.js +0 -14
- package/dist/controller/stscontrollerbase.js.map +0 -1
- package/dist/controller/stslatencycontroller.js +0 -28
- package/dist/controller/stslatencycontroller.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger/stsTransportLoggerWinston.js +0 -22
- package/dist/logger/stsTransportLoggerWinston.js.map +0 -1
- package/dist/logger/stsTransportWinston.js +0 -43
- package/dist/logger/stsTransportWinston.js.map +0 -1
- package/dist/middleware/serverNetworkMiddleware.js +0 -199
- package/dist/middleware/serverNetworkMiddleware.js.map +0 -1
- package/dist/network.js +0 -38
- package/dist/network.js.map +0 -1
- package/dist/process/masterprocessbase.js +0 -558
- package/dist/process/masterprocessbase.js.map +0 -1
- package/dist/process/processbase.js +0 -411
- package/dist/process/processbase.js.map +0 -1
- package/dist/process/serverprocessbase.js +0 -401
- package/dist/process/serverprocessbase.js.map +0 -1
- package/dist/process/singleprocessbase.js +0 -55
- package/dist/process/singleprocessbase.js.map +0 -1
- package/dist/process/workerprocessbase.js +0 -210
- package/dist/process/workerprocessbase.js.map +0 -1
- package/dist/publishertransports/publishTransportUtils.js +0 -47
- package/dist/publishertransports/publishTransportUtils.js.map +0 -1
- package/dist/route/stslatencyroute.js +0 -15
- package/dist/route/stslatencyroute.js.map +0 -1
- package/dist/route/stsrouterbase.js +0 -21
- package/dist/route/stsrouterbase.js.map +0 -1
- package/dist/stsexpressserver.js +0 -115
- package/dist/stsexpressserver.js.map +0 -1
- package/dist/validation/errors.js +0 -10
- package/dist/validation/errors.js.map +0 -1
- package/dist/vitesttesting/appConfig.js +0 -93
- package/dist/vitesttesting/appConfig.js.map +0 -1
- package/dist/vitesttesting/appSingleWSS.js +0 -122
- package/dist/vitesttesting/appSingleWSS.js.map +0 -1
- package/dist/vitesttesting/server.js +0 -15
- package/dist/vitesttesting/server.js.map +0 -1
- package/dist/vitesttesting/singleservertest.test.js +0 -286
- package/dist/vitesttesting/singleservertest.test.js.map +0 -1
- package/dist/vitesttesting/wsevents.js +0 -3
- package/dist/vitesttesting/wsevents.js.map +0 -1
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ServerProcessBase = void 0;
|
|
7
|
-
/* eslint @typescript-eslint/no-explicit-any: 0, @typescript-eslint/no-unused-vars: 0 */ // --> OFF
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
10
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
-
const stsutils_1 = require("@nsshunt/stsutils");
|
|
12
|
-
const processbase_1 = require("./processbase");
|
|
13
|
-
const prom_client_1 = require("prom-client");
|
|
14
|
-
const node_https_1 = require("node:https");
|
|
15
|
-
const node_http_1 = require("node:http");
|
|
16
|
-
const node_tls_1 = __importDefault(require("node:tls"));
|
|
17
|
-
const socket_io_1 = require("socket.io");
|
|
18
|
-
const stsexpressserver_1 = require("./../stsexpressserver");
|
|
19
|
-
const cluster_adapter_1 = require("@socket.io/cluster-adapter");
|
|
20
|
-
const redis_streams_adapter_1 = require("@socket.io/redis-streams-adapter");
|
|
21
|
-
//import { ClusterAdapterWithHeartbeat } from 'socket.io-adaptor';
|
|
22
|
-
//import { createAdapter } from "@socket.io/redis-adapter";
|
|
23
|
-
const redis_1 = require("redis");
|
|
24
|
-
const jayson_1 = __importDefault(require("jayson"));
|
|
25
|
-
const stsTransportLoggerWinston_1 = require("./../logger/stsTransportLoggerWinston");
|
|
26
|
-
/**
|
|
27
|
-
* todo
|
|
28
|
-
* @typedef {Object} options - todo
|
|
29
|
-
* @property {boolean} [wssServer=false] - Create a web socket server on this worker instance
|
|
30
|
-
*/
|
|
31
|
-
class ServerProcessBase extends processbase_1.ProcessBase {
|
|
32
|
-
#masterProcessExitTime = stsconfig_1.goptions.masterProcessExitTime;
|
|
33
|
-
#io = null;
|
|
34
|
-
#redisClient = null;
|
|
35
|
-
#httpServer = null;
|
|
36
|
-
#expressServer = null;
|
|
37
|
-
#sockets = [];
|
|
38
|
-
#shuttingDown = false;
|
|
39
|
-
constructor(options) {
|
|
40
|
-
super(options);
|
|
41
|
-
}
|
|
42
|
-
get httpServer() {
|
|
43
|
-
return this.#httpServer;
|
|
44
|
-
}
|
|
45
|
-
get io() {
|
|
46
|
-
return this.#io;
|
|
47
|
-
}
|
|
48
|
-
get expressServer() {
|
|
49
|
-
return this.#expressServer;
|
|
50
|
-
}
|
|
51
|
-
set expressServer(val) {
|
|
52
|
-
this.#expressServer = val;
|
|
53
|
-
}
|
|
54
|
-
// Setup server to Prometheus scrapes:
|
|
55
|
-
#SetupPrometheusEndPoints = (expressServer) => {
|
|
56
|
-
// AggregatorRegistry is required here in the worker as well as the master in order for prom-client to work correctly.
|
|
57
|
-
new prom_client_1.AggregatorRegistry();
|
|
58
|
-
const prefix = 'sts_';
|
|
59
|
-
(0, prom_client_1.collectDefaultMetrics)({
|
|
60
|
-
labels: { NODE_APP_INSTANCE: process.pid },
|
|
61
|
-
prefix: prefix
|
|
62
|
-
});
|
|
63
|
-
const c = new prom_client_1.Counter({
|
|
64
|
-
name: 'sts_test_counter',
|
|
65
|
-
help: 'Example of a counter',
|
|
66
|
-
labelNames: ['code'],
|
|
67
|
-
});
|
|
68
|
-
setInterval(() => {
|
|
69
|
-
c.inc({ code: 200 });
|
|
70
|
-
}, 1000).unref();
|
|
71
|
-
setInterval(() => {
|
|
72
|
-
c.inc({ code: 400 });
|
|
73
|
-
c.inc({ code: 'worker_' + process.pid });
|
|
74
|
-
}, 500).unref();
|
|
75
|
-
expressServer.get('/metrics', async (req, res) => {
|
|
76
|
-
try {
|
|
77
|
-
res.set('Content-Type', prom_client_1.register.contentType);
|
|
78
|
-
res.end(await prom_client_1.register.metrics());
|
|
79
|
-
}
|
|
80
|
-
catch (ex) {
|
|
81
|
-
res.status(500).end(ex);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
expressServer.get('/metrics/counter', async (req, res) => {
|
|
85
|
-
try {
|
|
86
|
-
res.set('Content-Type', prom_client_1.register.contentType);
|
|
87
|
-
res.end(await prom_client_1.register.getSingleMetricAsString('test_counter'));
|
|
88
|
-
}
|
|
89
|
-
catch (ex) {
|
|
90
|
-
res.status(500).end(ex);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
#SetupTLSServer = async (socket) => {
|
|
95
|
-
// Add a 'close' event handler to this instance of socket
|
|
96
|
-
this.LogInfoMessage('CONNECTED: ' + socket.remoteAddress + ':' + socket.remotePort + ' ' + process.pid);
|
|
97
|
-
this.#sockets.push(socket);
|
|
98
|
-
//const self = this;
|
|
99
|
-
socket.on('close', (data) => {
|
|
100
|
-
const index = this.#sockets.findIndex(function (o) {
|
|
101
|
-
return o.remoteAddress === socket.remoteAddress && o.remotePort === socket.remotePort;
|
|
102
|
-
});
|
|
103
|
-
if (index !== -1)
|
|
104
|
-
this.#sockets.splice(index, 1);
|
|
105
|
-
this.LogInfoMessage('CLOSED: ' + socket.remoteAddress + ' ' + socket.remotePort + ' ' + process.pid);
|
|
106
|
-
});
|
|
107
|
-
socket.on('data', (data) => {
|
|
108
|
-
this.LogInfoMessage('DATA ' + socket.remoteAddress + ': ' + socket.remotePort + ': ' + data);
|
|
109
|
-
socket.write(socket.remoteAddress + ':' + socket.remotePort + " said " + data + '\n');
|
|
110
|
-
// Write the data back to all the connected, the client will receive it as data from the server
|
|
111
|
-
/*
|
|
112
|
-
self.#sockets.forEach(function(socket, index, array) {
|
|
113
|
-
socket.write(socket.remoteAddress + ':' + socket.remotePort + " said " + data + '\n');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
#SetupRPCServer = async (socket) => {
|
|
120
|
-
this.LogInfoMessage('CONNECTED: ' + socket.remoteAddress + ':' + socket.remotePort + ' ' + process.pid);
|
|
121
|
-
socket.on('close', (data) => {
|
|
122
|
-
this.LogInfoMessage('CLOSED: ' + socket.remoteAddress + ' ' + socket.remotePort + ' ' + process.pid);
|
|
123
|
-
});
|
|
124
|
-
socket.on('data', (data) => {
|
|
125
|
-
this.LogInfoMessage('DATA ' + socket.remoteAddress + ': ' + data);
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
#SetupWSSServer = async () => {
|
|
129
|
-
// socket.io
|
|
130
|
-
// WebSocket
|
|
131
|
-
const options = {
|
|
132
|
-
transports: ["websocket"] // or [ "websocket", "polling" ] (to use long-poolling. Note that the order matters)
|
|
133
|
-
// The default path is /socket.io
|
|
134
|
-
// This can be changed with the path option as shown below
|
|
135
|
-
//,path: '/zzz'
|
|
136
|
-
};
|
|
137
|
-
//this.#io = require("socket.io")(this.#httpServer, options);
|
|
138
|
-
this.#io = new socket_io_1.Server(this.#httpServer, options);
|
|
139
|
-
if (this.options.useSocketIoRedisAdaptor) {
|
|
140
|
-
this.LogInfoMessage(`Using Redis for socket.io cluster management (worker)`);
|
|
141
|
-
if (this.options.socketIoRedisAdaptorUrl) {
|
|
142
|
-
this.LogInfoMessage(`Redis url: [${this.options.socketIoRedisAdaptorUrl}]`);
|
|
143
|
-
this.#redisClient = (0, redis_1.createClient)({ url: this.options.socketIoRedisAdaptorUrl });
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
this.LogInfoMessage(`Redis url: [localhost]`);
|
|
147
|
-
this.#redisClient = (0, redis_1.createClient)();
|
|
148
|
-
}
|
|
149
|
-
await this.#redisClient.connect();
|
|
150
|
-
//this.#redisClient = new Redis(this.options.socketIoRedisAdaptorUrl as string);
|
|
151
|
-
this.#io.adapter((0, redis_streams_adapter_1.createAdapter)(this.#redisClient));
|
|
152
|
-
this.LogInfoMessage(`Redis successfully connected.`);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
if (this.options.clusterMode) {
|
|
156
|
-
this.#io.adapter((0, cluster_adapter_1.createAdapter)());
|
|
157
|
-
this.LogInfoMessage(`Using nodejs cluster mode for socket.io cluster management`);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
this.LogInfoMessage(`Not using any adaptors for socket.io cluster management.}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
// To use a seperate socket server, the code below can be applied.
|
|
164
|
-
// this.#io = require("socket.io")(options);
|
|
165
|
-
// this.#io.adapter(createAdapter());
|
|
166
|
-
// this.#io.listen(3006);
|
|
167
|
-
this.#io.engine.on("connection_error", (err) => {
|
|
168
|
-
this.LogInfoMessage(err.req); // the request object
|
|
169
|
-
this.LogInfoMessage(err.code); // the error code, for example 1
|
|
170
|
-
this.LogInfoMessage(err.message); // the error message, for example "Session ID unknown"
|
|
171
|
-
this.LogInfoMessage(err.context); // some additional error context
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
#GetTLSOptions = () => {
|
|
175
|
-
return {
|
|
176
|
-
key: node_fs_1.default.readFileSync(this.options.httpsServerKeyPath),
|
|
177
|
-
cert: node_fs_1.default.readFileSync(this.options.httpsServerCertificatePath)
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
#SetupExpressServer = async (useTls) => {
|
|
181
|
-
if (useTls) {
|
|
182
|
-
this.#httpServer = (0, node_https_1.createServer)(this.#GetTLSOptions(), this.#expressServer.App);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
this.#httpServer = (0, node_http_1.createServer)(this.#expressServer.App);
|
|
186
|
-
}
|
|
187
|
-
if (this.options.prometheusSupport === true) {
|
|
188
|
-
this.#SetupPrometheusEndPoints(this.#expressServer.App);
|
|
189
|
-
}
|
|
190
|
-
if (this.options.wssServer === true) {
|
|
191
|
-
await this.#SetupWSSServer();
|
|
192
|
-
}
|
|
193
|
-
// https://stackoverflow.com/questions/21342828/node-express-unix-domain-socket-permissions
|
|
194
|
-
//@@httpServer.listen('/tmp/stsrest01.sock').on('listening', () =>
|
|
195
|
-
//@@httpServer.listen('/var/run/sts/stsrest01.sock').on('listening', () =>
|
|
196
|
-
this.#httpServer.listen(this.options.listenPort, () => {
|
|
197
|
-
//@@chmodSync(this.options.port, 511);
|
|
198
|
-
}).on('listening', () => {
|
|
199
|
-
this.LogInfoMessage(`live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
#SetupTCPRawServer = async () => {
|
|
203
|
-
// The second parameter is the automatic listener for the secureConnection event from the tls.Server class
|
|
204
|
-
this.#httpServer = node_tls_1.default.createServer(this.#GetTLSOptions(), this.#SetupTLSServer);
|
|
205
|
-
this.#httpServer.listen(this.options.listenPort, 'stscore.stsmda.org', () => {
|
|
206
|
-
this.LogInfoMessage('TCP Server is running on port ' + this.options.listenPort + '.');
|
|
207
|
-
}).on('listening', () => {
|
|
208
|
-
this.LogInfoMessage(`TCP live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
|
|
209
|
-
});
|
|
210
|
-
};
|
|
211
|
-
#SetupJSONRPCServer = async () => {
|
|
212
|
-
const jaysonServer = new jayson_1.default.server();
|
|
213
|
-
// Supported methods here - move somewhere else ...
|
|
214
|
-
jaysonServer.method("add", function (args, callback) {
|
|
215
|
-
callback(null, args[0] + args[1]);
|
|
216
|
-
});
|
|
217
|
-
this.#httpServer = jaysonServer.tls(this.#GetTLSOptions());
|
|
218
|
-
this.#httpServer.on('secureConnection', this.#SetupRPCServer);
|
|
219
|
-
this.#httpServer.listen(this.options.listenPort, 'stscore.stsmda.org', () => {
|
|
220
|
-
this.LogInfoMessage('JSON RPC 2.0 Server is running on port ' + this.options.listenPort + '.');
|
|
221
|
-
}).on('listening', () => {
|
|
222
|
-
this.LogInfoMessage(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
|
|
223
|
-
});
|
|
224
|
-
};
|
|
225
|
-
get shuttingDown() {
|
|
226
|
-
return this.#shuttingDown;
|
|
227
|
-
}
|
|
228
|
-
TerminateSocketIO = async () => {
|
|
229
|
-
if (this.options.wssServer === true && this.#io !== null) {
|
|
230
|
-
const logPrefix = `ServerProcessBase:TerminateSockets():${process.pid}:`;
|
|
231
|
-
this.LogInfoMessage(`${logPrefix} Disconnect SocketIO Sockets.`);
|
|
232
|
-
await (0, stsutils_1.Sleep)(250);
|
|
233
|
-
await this.#io?.of('/').adapter.close();
|
|
234
|
-
if (this.socketIoServerHelper !== null) {
|
|
235
|
-
await this.socketIoServerHelper.CloseAdaptors();
|
|
236
|
-
await (0, stsutils_1.Sleep)(50);
|
|
237
|
-
if (this.#redisClient) {
|
|
238
|
-
this.#redisClient.disconnect();
|
|
239
|
-
await (0, stsutils_1.Sleep)(50);
|
|
240
|
-
}
|
|
241
|
-
this.LogInfoMessage(`${logPrefix} this.socketIoServerHelper.DisconnectSockets()`);
|
|
242
|
-
await this.socketIoServerHelper.DisconnectSockets();
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
this.LogInfoMessage(`${logPrefix} this.#io.disconnectSockets()`);
|
|
246
|
-
if (this.#redisClient) {
|
|
247
|
-
this.#redisClient.disconnect();
|
|
248
|
-
await (0, stsutils_1.Sleep)(50);
|
|
249
|
-
}
|
|
250
|
-
this.#io.disconnectSockets();
|
|
251
|
-
}
|
|
252
|
-
this.socketIoServerHelper = null;
|
|
253
|
-
this.#io = null;
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
TerminateHTTPServer = async () => {
|
|
257
|
-
const logPrefix = `ServerProcessBase:TerminateHTTPServer():${process.pid}:`;
|
|
258
|
-
if (this.#httpServer !== null) {
|
|
259
|
-
if (stsconfig_1.goptions.STSServerType.localeCompare('TCPRAW_TLS') === 0) {
|
|
260
|
-
this.#sockets.forEach((socket, index, array) => {
|
|
261
|
-
this.LogInfoMessage(chalk_1.default.yellow(`${logPrefix} TCP Socket destroy, remote address: [${socket.remoteAddress}], remote port: [${socket.remotePort}]`));
|
|
262
|
-
socket.destroy();
|
|
263
|
-
//socket.end();
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
this.LogInfoMessage(`${logPrefix} Closing httpServer.`);
|
|
267
|
-
await this.#httpServer.close();
|
|
268
|
-
this.#httpServer = null;
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
// Terminate in order;
|
|
272
|
-
// forked worker threads (send signal)
|
|
273
|
-
// De-Register service
|
|
274
|
-
// systeminformation observers
|
|
275
|
-
// instrument timers (gauge etc.)
|
|
276
|
-
// publisher
|
|
277
|
-
// terminate UI (if loaded)
|
|
278
|
-
Terminate = async (clusterPerformExit, signal) => {
|
|
279
|
-
const logPrefix = `ServerProcessBase:Terminate():${process.pid}:`;
|
|
280
|
-
if (this.#shuttingDown === false) {
|
|
281
|
-
this.#shuttingDown = true;
|
|
282
|
-
if (signal) {
|
|
283
|
-
this.LogInfoMessage(this.GetSignalColour(signal)(`${logPrefix} Received signal: ${signal}`));
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
this.LogInfoMessage(this.GetSignalColour(null)(`${logPrefix} Received Terminate without signal.`));
|
|
287
|
-
}
|
|
288
|
-
await this.ProcessTerminate();
|
|
289
|
-
this.TerminateUIController();
|
|
290
|
-
await this.TerminateSocketIO();
|
|
291
|
-
await this.TerminateHTTPServer();
|
|
292
|
-
await this.TerminateDatabase();
|
|
293
|
-
// Output final messages here (before TerminateInstrumentController)
|
|
294
|
-
if (this.options.clusterMode) {
|
|
295
|
-
this.LogInfoMessage(`${logPrefix} clusterPerformExit value: [${clusterPerformExit}]`);
|
|
296
|
-
if (clusterPerformExit) {
|
|
297
|
-
this.LogInfoMessage(`${logPrefix} Process will self terminate with process.exit(0).`);
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
this.LogInfoMessage(`${logPrefix} Child process will not self terminate. Terminate will be handled by master process.`);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
this.TerminateInstrumentController();
|
|
304
|
-
//@@ always return here appears to always cleanly exit
|
|
305
|
-
// and cleanly exit from socket.io cluster adaptor
|
|
306
|
-
// without return here, socket.io cluster adaptor terminates in an error state
|
|
307
|
-
// as the implementation relies on cluster.on to send messages to worker threads
|
|
308
|
-
// but these have already been closed from the process.exit(0) below.
|
|
309
|
-
await (0, stsutils_1.Sleep)(1000); // Allow socket.io time to clean-up
|
|
310
|
-
if (this.options.clusterMode === true) {
|
|
311
|
-
if (clusterPerformExit === true) {
|
|
312
|
-
setTimeout(() => {
|
|
313
|
-
process.exit(0);
|
|
314
|
-
}, 0);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
this.ProcessExit(this.#masterProcessExitTime);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
this.LogInfoMessage(`${logPrefix} Process already terminating.`);
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
async SetupServer() {
|
|
326
|
-
return new Promise((resolve, reject) => {
|
|
327
|
-
try {
|
|
328
|
-
this.SetupInstrumentation();
|
|
329
|
-
setTimeout(async () => {
|
|
330
|
-
try {
|
|
331
|
-
await this.SetupServerEx();
|
|
332
|
-
resolve(true);
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
reject(error);
|
|
336
|
-
}
|
|
337
|
-
}, 100);
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
reject(error);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
ProcessStarted() {
|
|
345
|
-
const transport = new stsTransportLoggerWinston_1.STSTransportLoggerWinston({
|
|
346
|
-
stsApp: this
|
|
347
|
-
});
|
|
348
|
-
setTimeout(() => {
|
|
349
|
-
this.options.logger.add(transport);
|
|
350
|
-
}, 0);
|
|
351
|
-
}
|
|
352
|
-
async SetupServerEx() {
|
|
353
|
-
this.LogInfoMessage(chalk_1.default.green(`ServerProcessBase:SetupServerEx(): Main Process:${process.pid} Starting ...`));
|
|
354
|
-
this.ProcessStartup();
|
|
355
|
-
if (this.options.expressServerRouteFactory || this.options.expressServerRouteStaticFactory) {
|
|
356
|
-
this.expressServer = new stsexpressserver_1.STSExpressServer(this.options, this);
|
|
357
|
-
}
|
|
358
|
-
this.LogInfoMessage(`ServerProcessBase:SetupServerEx(): Worker instance starting. Service instance Id: [${this.options.serviceInstanceId}]`);
|
|
359
|
-
// Signal Codes
|
|
360
|
-
// https://en.wikipedia.org/wiki/Signal_(IPC)
|
|
361
|
-
process.on('SIGTERM', async () => {
|
|
362
|
-
this.LogInfoMessage(`ServerProcessBase:SetupServerEx(): SIGTERM signal received for worker: ${process.pid}`);
|
|
363
|
-
await this.Terminate(true, true);
|
|
364
|
-
});
|
|
365
|
-
process.on('SIGINT', async () => {
|
|
366
|
-
this.LogInfoMessage(`ServerProcessBase:SetupServerEx(): SIGINT signal received for worker: ${process.pid}`);
|
|
367
|
-
await this.Terminate(true, true);
|
|
368
|
-
});
|
|
369
|
-
process.on('exit', (code) => {
|
|
370
|
-
if (code === 0) {
|
|
371
|
-
this.LogInfoMessage(chalk_1.default.green(`ServerProcessBase:SetupServerEx(): Process: ${process.pid} terminated gracefully with code: ${code}`));
|
|
372
|
-
}
|
|
373
|
-
else {
|
|
374
|
-
this.LogInfoMessage(chalk_1.default.red(`ServerProcessBase:SetupServerEx(): Process: ${process.pid} terminated with code: ${code}`));
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
await this.SetupSTSServer();
|
|
378
|
-
this.ProcessStarted();
|
|
379
|
-
this.LogInfoMessage(chalk_1.default.green(`ServerProcessBase:SetupServerEx(): Main Process:${process.pid} Started`));
|
|
380
|
-
return true;
|
|
381
|
-
}
|
|
382
|
-
;
|
|
383
|
-
SetupSTSServer = async () => {
|
|
384
|
-
switch (stsconfig_1.goptions.STSServerType) {
|
|
385
|
-
case 'EXPRESS':
|
|
386
|
-
await this.#SetupExpressServer(false);
|
|
387
|
-
break;
|
|
388
|
-
case 'EXPRESS_TLS':
|
|
389
|
-
await this.#SetupExpressServer(true);
|
|
390
|
-
break;
|
|
391
|
-
case 'TCPRAW_TLS':
|
|
392
|
-
await this.#SetupTCPRawServer();
|
|
393
|
-
break;
|
|
394
|
-
case 'JSONRPC2_TLS':
|
|
395
|
-
await this.#SetupJSONRPCServer();
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
exports.ServerProcessBase = ServerProcessBase;
|
|
401
|
-
//# sourceMappingURL=serverprocessbase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serverprocessbase.js","sourceRoot":"","sources":["../../src/process/serverprocessbase.ts"],"names":[],"mappings":";;;;;;AAAA,wFAAwF,CAAE,UAAU;AACpG,kDAA0B;AAE1B,kDAA6C;AAE7C,sDAAwB;AAExB,gDAAqD;AAGrD,+CAA4C;AAE5C,6CAA0F;AAE1F,2CAA8D;AAC9D,yCAAwC;AACxC,wDAA0B;AAG1B,yCAAkD;AAClD,4DAAwD;AAGxD,gEAAkF;AAClF,4EAAiE;AACjE,kEAAkE;AAElE,2DAA2D;AAE3D,iCAAsD;AAGtD,oDAA2B;AAE3B,qFAAiF;AAEjF;;;;GAIG;AACH,MAAsB,iBAAkB,SAAQ,yBAAW;IAEvD,sBAAsB,GAAG,oBAAQ,CAAC,qBAAqB,CAAC;IACxD,GAAG,GAAkB,IAAI,CAAC;IAC1B,YAAY,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AAC,CAAC;YAC/H,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,IAAI,CAAC,cAAc,CAAC,eAAK,CAAC,KAAK,CAAC,mDAAmD,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;QAE3G,OAAO,IAAI,CAAC;IAChB,CAAC;IAAA,CAAC;IAEF,cAAc,GAAG,KAAK,IAAkB,EAAE;QACtC,QAAQ,oBAAQ,CAAC,aAAa,EAAE,CAAC;YACjC,KAAK,SAAS;gBACV,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBACtC,MAAM;YACV,KAAK,aAAa;gBACd,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBACrC,MAAM;YACV,KAAK,YAAY;gBACb,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAChC,MAAM;YACV,KAAK,cAAc;gBACf,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBACjC,MAAM;QACV,CAAC;IACL,CAAC,CAAA;CACJ;AA7ZD,8CA6ZC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SingleProcessBase = void 0;
|
|
7
|
-
/* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
|
|
8
|
-
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
9
|
-
const stsobservability_1 = require("@nsshunt/stsobservability");
|
|
10
|
-
const serverprocessbase_1 = require("./serverprocessbase");
|
|
11
|
-
const systeminformation_1 = __importDefault(require("systeminformation")); // https://systeminformation.io/
|
|
12
|
-
class SingleProcessBase extends serverprocessbase_1.ServerProcessBase {
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {SingleProcessBaseOptions} options
|
|
16
|
-
*/
|
|
17
|
-
constructor(options) {
|
|
18
|
-
super(options);
|
|
19
|
-
}
|
|
20
|
-
CollectAdditionalTelemetry() {
|
|
21
|
-
const siValueObject = {
|
|
22
|
-
currentLoad: 'currentLoad'
|
|
23
|
-
};
|
|
24
|
-
systeminformation_1.default.get(siValueObject).then(data => {
|
|
25
|
-
this.UpdateInstrument(stsobservability_1.Gauge.CPU_SYSTEM_LOAD_GAUGE, {
|
|
26
|
-
val: data.currentLoad.currentLoad
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
GetAdditionalInstruments() {
|
|
31
|
-
return [
|
|
32
|
-
[stsobservability_1.Gauge.CPU_SYSTEM_LOAD_GAUGE, stsobservability_1.GaugeTypes.INSTRUMENT_GAUGE, {
|
|
33
|
-
interval: stsconfig_1.goptions.instrumentationObservationInterval,
|
|
34
|
-
sampleSize: stsconfig_1.goptions.instrumentationTimeWindow
|
|
35
|
-
}]
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* UIController (instance of UIController) to manage a console based user interface associated for this node application.
|
|
40
|
-
* @returns UIController instance to manage a console based user interface associated for this node application. Null for no capability.
|
|
41
|
-
*/
|
|
42
|
-
GetUIController() {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
SetupServerEx = async () => {
|
|
46
|
-
await super.SetupServerEx();
|
|
47
|
-
this.LogSystemTelemetry();
|
|
48
|
-
return true;
|
|
49
|
-
};
|
|
50
|
-
async TerminateApplication() {
|
|
51
|
-
await this.Terminate(false, 'SIGINT');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.SingleProcessBase = SingleProcessBase;
|
|
55
|
-
//# sourceMappingURL=singleprocessbase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleprocess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