@nsshunt/stsappframework 3.1.17 → 3.1.18

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.
@@ -29,6 +29,7 @@ import { InstrumentDefinitions } from '@nsshunt/stspublisherserver'
29
29
  import { IPCMessagePayload, IPCMessageCommand } from './commonTypes'
30
30
 
31
31
  import { STSTransportLoggerWinston } from './stsTransportLoggerWinston'
32
+ import { ISTSLogger } from "@nsshunt/stsutils";
32
33
 
33
34
  export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
34
35
  {
@@ -99,7 +100,7 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
99
100
  }
100
101
  }
101
102
 
102
- #InitCluster = (LogEx: any) =>
103
+ #InitCluster = () =>
103
104
  {
104
105
  cluster.on('listening', () => {
105
106
  let allListening = true;
@@ -111,13 +112,13 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
111
112
  }
112
113
 
113
114
  if (allListening) {
114
- LogEx(`Service instance started.`);
115
+ this.LogInfoMessage(`Service instance started.`);
115
116
  }
116
117
  });
117
118
  };
118
119
 
119
120
  // https://github.com/siimon/prom-client/blob/master/example/cluster.js
120
- #SetupPrometheusForMaster = (LogEx: any) => {
121
+ #SetupPrometheusForMaster = () => {
121
122
  this.#metricsServer = express();
122
123
  this.#aggregatorRegistry = new AggregatorRegistry();
123
124
 
@@ -158,7 +159,7 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
158
159
  //@@chmodSync(this.options.port, 511);
159
160
  }).on('listening', () =>
160
161
  {
161
- LogEx(`Prometheus scrapes ready and live on ${this.options.endpoint}:${this.options.prometheusClusterPort}/metrics`);
162
+ this.LogInfoMessage(`Prometheus scrapes ready and live on ${this.options.endpoint}:${this.options.prometheusClusterPort}/metrics`);
162
163
  });
163
164
  } catch (error)
164
165
  {
@@ -231,26 +232,26 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
231
232
  if (cluster.workers && cluster.workers[id]) {
232
233
  const worker = cluster.workers[id] as Worker;
233
234
  if (worker.process) {
234
- this.LogEx(chalk.grey(`Sending terminate message `) + chalk.yellow(`(initiated by ${signal})`) + chalk.grey(` for worker PID: ${worker.process.pid}`));
235
+ this.LogInfoMessage(chalk.grey(`Sending terminate message `) + chalk.yellow(`(initiated by ${signal})`) + chalk.grey(` for worker PID: ${worker.process.pid}`));
235
236
  const command: string = (killProcess ? 'TerminateAndKill' : 'Terminate');
236
237
  try {
237
238
  worker.send( { command } );
238
239
  //worker.process.send( { command } );
239
240
  } catch (error) {
240
- this.LogEx(chalk.red(`MasterProcessBase:#_KillWorker() (1): id: [${id}], signal: [${signal}], killProcess: [${killProcess}], error: [${error}]`));
241
+ this.LogInfoMessage(chalk.red(`MasterProcessBase:#_KillWorker() (1): id: [${id}], signal: [${signal}], killProcess: [${killProcess}], error: [${error}]`));
241
242
  return false;
242
243
  }
243
244
  return true;
244
245
  } else {
245
- this.LogEx(chalk.red(`MasterProcessBase:#_KillWorker(): Could not kill worker with id: [${id}]. The process does not exists`));
246
+ this.LogInfoMessage(chalk.red(`MasterProcessBase:#_KillWorker(): Could not kill worker with id: [${id}]. The process does not exists`));
246
247
  return false;
247
248
  }
248
249
  } else {
249
- this.LogEx(chalk.red(`MasterProcessBase:#_KillWorker(): Could not kill worker with id: [${id}]. Worker does not exist within workers collection`));
250
+ this.LogInfoMessage(chalk.red(`MasterProcessBase:#_KillWorker(): Could not kill worker with id: [${id}]. Worker does not exist within workers collection`));
250
251
  return false;
251
252
  }
252
253
  } catch (error) {
253
- this.LogEx(chalk.red(`MasterProcessBase:#_KillWorker() (2): id: [${id}], signal: [${signal}], killProcess: [${killProcess}], error: [${error}]`));
254
+ this.LogInfoMessage(chalk.red(`MasterProcessBase:#_KillWorker() (2): id: [${id}], signal: [${signal}], killProcess: [${killProcess}], error: [${error}]`));
254
255
  return false;
255
256
  }
256
257
  }
@@ -278,11 +279,11 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
278
279
  return this.#_KillWorker(id, signal, killProcess);
279
280
  }
280
281
  } else {
281
- this.LogEx(chalk.yellow(`MasterProcessBase:KillWorker(): Not allowed to kill the last worker process.`));
282
+ this.LogInfoMessage(chalk.yellow(`MasterProcessBase:KillWorker(): Not allowed to kill the last worker process.`));
282
283
  return false;
283
284
  }
284
285
  } catch (error) {
285
- this.LogEx(chalk.red(`MasterProcessBase:KillWorker(): id: [${id}], signal: [${signal}], killProcess: [${killProcess}], error: [${error}]`));
286
+ this.LogInfoMessage(chalk.red(`MasterProcessBase:KillWorker(): id: [${id}], signal: [${signal}], killProcess: [${killProcess}], error: [${error}]`));
286
287
  return false;
287
288
  }
288
289
  }
@@ -303,7 +304,7 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
303
304
  }
304
305
  });
305
306
  } catch (error) {
306
- this.LogEx(chalk.red(`MasterProcessBase:KillWorkers(): signal: [${signal}], keepOne: [${keepOne}], error: [${error}]`));
307
+ this.LogInfoMessage(chalk.red(`MasterProcessBase:KillWorkers(): signal: [${signal}], keepOne: [${keepOne}], error: [${error}]`));
307
308
  }
308
309
  }
309
310
 
@@ -393,11 +394,11 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
393
394
 
394
395
  worker.on('exit', (code, signal) => {
395
396
  if (signal) {
396
- this.LogEx(`Worker: ${worker.process.pid} was killed by signal: ${signal}`);
397
+ this.LogInfoMessage(`Worker: ${worker.process.pid} was killed by signal: ${signal}`);
397
398
  } else if (code !== 0) {
398
- this.LogEx(`Worker: ${worker.process.pid} exited with error code: ${code}`);
399
+ this.LogInfoMessage(`Worker: ${worker.process.pid} exited with error code: ${code}`);
399
400
  } else {
400
- this.LogEx(`Worker: ${worker.process.pid} exited successfully, code: ${code}, signal: ${signal}`);
401
+ this.LogInfoMessage(`Worker: ${worker.process.pid} exited successfully, code: ${code}, signal: ${signal}`);
401
402
  }
402
403
  });
403
404
 
@@ -416,8 +417,7 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
416
417
 
417
418
  worker.on('error', (error) => {
418
419
  const message = chalk.red(`#SpawnWorker():worker.on('error'): Error: [${error}]`);
419
- this.#LogDebugMessage(message);
420
- this.LogEx(message);
420
+ this.LogErrorMessage(message);
421
421
  });
422
422
 
423
423
  return worker.id;
@@ -443,9 +443,8 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
443
443
  SetupServerEx = async () =>
444
444
  {
445
445
  this.ProcessStartup();
446
- const LogEx = this.LogEx;
447
446
 
448
- LogEx(`Service instance starting. Instance Id: [${this.options.serviceInstanceId}]`);
447
+ this.LogInfoMessage(`Service instance starting. Instance Id: [${this.options.serviceInstanceId}]`);
449
448
 
450
449
  this.LogSystemTelemetry();
451
450
 
@@ -453,15 +452,15 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
453
452
  // setup connections between the workers
454
453
  if (this.options.wssServer === true) {
455
454
  if (this.options.useRedisAdaptor) {
456
- LogEx(`Using Redis for socket.io cluster management (master)`);
455
+ this.LogInfoMessage(`Using Redis for socket.io cluster management (master)`);
457
456
  } else {
458
- LogEx(`Using nodejs cluster mode for socket.io cluster management`);
457
+ this.LogInfoMessage(`Using nodejs cluster mode for socket.io cluster management`);
459
458
  setupPrimary();
460
459
  }
461
460
  }
462
461
 
463
462
  if (this.options.prometheusSupport === true) {
464
- this.#SetupPrometheusForMaster(LogEx);
463
+ this.#SetupPrometheusForMaster();
465
464
  }
466
465
 
467
466
  const numCPUs = await this.GetNumCPUs();
@@ -469,34 +468,34 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
469
468
  this.#SpawnWorker();
470
469
  }
471
470
 
472
- this.#InitCluster(LogEx);
471
+ this.#InitCluster();
473
472
 
474
473
  cluster.on('listening', (worker, address) =>
475
474
  {
476
- LogEx(`Worker process ${worker.process.pid} is listening at address: ${JSON.stringify(address)}`);
475
+ this.LogInfoMessage(`Worker process ${worker.process.pid} is listening at address: ${JSON.stringify(address)}`);
477
476
  });
478
477
 
479
478
  //Setting up lifecycle event listeners for worker processes
480
479
  cluster.on('online', worker =>
481
480
  {
482
- LogEx(`Worker process ${worker.process.pid} is online`);
481
+ this.LogInfoMessage(`Worker process ${worker.process.pid} is online`);
483
482
  });
484
483
 
485
484
  cluster.on('exit', (worker, code, signal) => {
486
485
  if ((code !== null && code === 0) || (signal === 'SIGINT')) {
487
- LogEx(chalk.green(`Process ${worker.process.pid} terminated gracefully with code: ${code}, signal: ${signal}`));
486
+ this.LogInfoMessage(chalk.green(`Process ${worker.process.pid} terminated gracefully with code: ${code}, signal: ${signal}`));
488
487
  this.DecWorkers();
489
488
  } else if ((code !== null && code === 15) || (signal === 'SIGTERM')) {
490
489
  this.DecWorkers();
491
- LogEx(chalk.red(`Process ${worker.process.pid} terminated with code: ${code}, signal: ${signal}`));
490
+ this.LogInfoMessage(chalk.red(`Process ${worker.process.pid} terminated with code: ${code}, signal: ${signal}`));
492
491
  } else {
493
492
  this.DecWorkers();
494
- LogEx(chalk.red(`worker ${worker.process.pid} died`));
495
- LogEx(chalk.red(`code: ${code}`));
496
- LogEx(chalk.red(`signal: ${signal}`));
497
- LogEx(chalk.red('process terminated in an error state'));
493
+ this.LogInfoMessage(chalk.red(`worker ${worker.process.pid} died`));
494
+ this.LogInfoMessage(chalk.red(`code: ${code}`));
495
+ this.LogInfoMessage(chalk.red(`signal: ${signal}`));
496
+ this.LogInfoMessage(chalk.red('process terminated in an error state'));
498
497
  if (goptions.respawnOnFail === true) {
499
- LogEx(chalk.magenta(`Attemping to respawn worker`));
498
+ this.LogInfoMessage(chalk.magenta(`Attemping to respawn worker`));
500
499
  this.#SpawnWorker();
501
500
  }
502
501
  }
@@ -526,35 +525,35 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
526
525
 
527
526
  if (this.GetUIController() !== null)
528
527
  {
529
- LogEx('Destroy the user interface controller.');
528
+ this.LogInfoMessage('Destroy the user interface controller.');
530
529
  this.GetUIController().DestroyUI();
531
530
  }
532
531
 
533
532
  if (signal) {
534
- LogEx(this.GetSignalColour(signal)(`Main Process (masterprocess): ${process.pid} received signal: ${signal}`));
533
+ this.LogInfoMessage(this.GetSignalColour(signal)(`Main Process (masterprocess): ${process.pid} received signal: ${signal}`));
535
534
  } else {
536
- LogEx(this.GetSignalColour(null)(`Main Process (masterprocess): ${process.pid} received Terminate without signal.`));
535
+ this.LogInfoMessage(this.GetSignalColour(null)(`Main Process (masterprocess): ${process.pid} received Terminate without signal.`));
537
536
  }
538
537
 
539
- LogEx(`De-Registering service.`);
538
+ this.LogInfoMessage(`De-Registering service.`);
540
539
  //@@ De-register here ...
541
540
 
542
541
  if (this.#httpServer !== null) {
543
- LogEx(`Closing httpServer.`);
542
+ this.LogInfoMessage(`Closing httpServer.`);
544
543
  await this.#httpServer.close();
545
544
  this.#httpServer = null;
546
545
  }
547
546
 
548
- LogEx(`Stopping instruments.`);
547
+ this.LogInfoMessage(`Stopping instruments.`);
549
548
  //@@StopInstruments(this.instruments);
550
549
 
551
550
  //@@endpublish was here (and working ...)
552
551
 
553
- LogEx('Killing Workers.');
552
+ this.LogInfoMessage('Killing Workers.');
554
553
  this.KillWorkers(signal);
555
554
 
556
555
  if (this.options.useDatabase) {
557
- LogEx(`Ending database connections and pools.`);
556
+ this.LogInfoMessage(`Ending database connections and pools.`);
558
557
  await this.TerminateDatabase();
559
558
  //await this.accessLayer.enddatabase();
560
559
  }
@@ -562,7 +561,7 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
562
561
  // Now allow some time for the workers to die and send any remaining messages ...
563
562
  //if (this.InstrumentController && this.InstrumentController.Workers.length > 0) {
564
563
  if (this.InstrumentController) {
565
- LogEx(`Ending publisher.`);
564
+ this.LogInfoMessage(`Ending publisher.`);
566
565
  setTimeout(() => {
567
566
  if (this.InstrumentController) {
568
567
  this.InstrumentController.InstrumentTerminate();
@@ -572,11 +571,11 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
572
571
 
573
572
  if (this.options.processExitOnTerminate && this.options.processExitOnTerminate === true) {
574
573
  setTimeout(() => {
575
- LogEx(`Performing process.exit(0).`);
574
+ this.LogInfoMessage(`Performing process.exit(0).`);
576
575
  process.exit(0);
577
576
  }, this.#childProcessExitTime + this.#masterProcessExitTime); // Give the workers time to terminate gracefully
578
577
  } else {
579
- LogEx(`Performing process.exit(0) - Immediate.`);
578
+ this.LogInfoMessage(`Performing process.exit(0) - Immediate.`);
580
579
  }
581
580
  }
582
581
  }
@@ -595,9 +594,9 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
595
594
  {
596
595
  if (code === 0)
597
596
  {
598
- LogEx(chalk.green(`Main Process: ${process.pid} terminated gracefully with code: ${code}`));
597
+ this.LogInfoMessage(chalk.green(`Main Process: ${process.pid} terminated gracefully with code: ${code}`));
599
598
  } else {
600
- LogEx(chalk.red(`Main Process: ${process.pid} terminated with code: ${code}`));
599
+ this.LogInfoMessage(chalk.red(`Main Process: ${process.pid} terminated with code: ${code}`));
601
600
  }
602
601
  });
603
602
 
@@ -609,21 +608,21 @@ export class MasterProcessBase extends ProcessBase implements IMasterProcessBase
609
608
 
610
609
  this.MasterStarted();
611
610
 
612
- LogEx(chalk.green(`Master process:${process.pid} started`));
611
+ this.LogInfoMessage(chalk.green(`Master process:${process.pid} started`));
613
612
  }
614
613
 
615
614
  BroadcastDataToWorkers = (command: any, data: any) => {
616
615
  try {
617
616
  for (const id in cluster.workers) {
618
617
  try {
619
- //@@LogEx(chalk.gray(`Sending message to worker PID: ${cluster.workers[id].process.pid}`));
618
+ //@@this.LogInfoMessage(chalk.gray(`Sending message to worker PID: ${cluster.workers[id].process.pid}`));
620
619
  (cluster.workers[id] as Worker).process.send( { command: command, data: data } );
621
620
  } catch (error) {
622
- //@@LogEx(error);
621
+ //@@this.LogInfoMessage(error);
623
622
  }
624
623
  }
625
624
  } catch (error) {
626
- //@@LogEx(error);
625
+ //@@this.LogInfoMessage(error);
627
626
  }
628
627
  }
629
628
  }
@@ -71,21 +71,11 @@ export abstract class ProcessBase extends STSOptionsBase implements IProcessBase
71
71
  }
72
72
 
73
73
  LogErrorMessage(message: any) {
74
- const msg = this.#GetFormattedLogMessage(message);
75
- this.options.logger.error(msg);
76
-
77
- this.UpdateInstrument(Gauge.LOGGER, {
78
- LogMessage: msg
79
- } as InstrumentLogTelemetry);
74
+ this.options.logger.error(this.#GetFormattedLogMessage(message));
80
75
  }
81
76
 
82
77
  LogInfoMessage(message: any) {
83
- const msg = this.#GetFormattedLogMessage(message);
84
- this.options.logger.info(msg);
85
-
86
- this.UpdateInstrument(Gauge.LOGGER, {
87
- LogMessage: msg
88
- } as InstrumentLogTelemetry);
78
+ this.options.logger.info(this.#GetFormattedLogMessage(message));
89
79
  }
90
80
 
91
81
  LogMessageToLoggerInstrument(message: any) {
@@ -272,10 +262,6 @@ export abstract class ProcessBase extends STSOptionsBase implements IProcessBase
272
262
  return this.#instrumentController;
273
263
  }
274
264
 
275
- LogEx = (message: any) => {
276
- this.LogInfoMessage(message);
277
- }
278
-
279
265
  InstrumentExists(instrumentName: Gauge): boolean
280
266
  {
281
267
  if (this.#instrumentController) {
@@ -347,13 +333,13 @@ export abstract class ProcessBase extends STSOptionsBase implements IProcessBase
347
333
  try {
348
334
  const retVal = await (this.accessLayer as PGAccessLayer).getResourceCount();
349
335
  if (retVal.status !== StatusCodes.OK) {
350
- this.LogEx(chalk.red(`Unable to get resources from the database. Is the database running? [${JSON.stringify(retVal)}]`));
336
+ this.LogInfoMessage(chalk.red(`Unable to get resources from the database. Is the database running? [${JSON.stringify(retVal)}]`));
351
337
  //@@exit(1);
352
338
  } else {
353
- this.LogEx(chalk.green(`Database connection successful. Resources: [${retVal.detail.count}]`));
339
+ this.LogInfoMessage(chalk.green(`Database connection successful. Resources: [${retVal.detail.count}]`));
354
340
  }
355
341
  } catch (error) {
356
- this.LogEx(chalk.red(`Unable to get resources from the database. Is the database running? Error: [${error}]`));
342
+ this.LogInfoMessage(chalk.red(`Unable to get resources from the database. Is the database running? Error: [${error}]`));
357
343
  //@@exit(1);
358
344
  }
359
345
  })();
@@ -399,17 +385,17 @@ export abstract class ProcessBase extends STSOptionsBase implements IProcessBase
399
385
 
400
386
  const hostaddr = GetFirstNetworkInterface();
401
387
  if (hostaddr !== null) {
402
- this.LogEx(`Host Address: ${hostaddr}`);
388
+ this.LogInfoMessage(`Host Address: ${hostaddr}`);
403
389
  } else {
404
- this.LogEx(`Unknown Host Address.`);
390
+ this.LogInfoMessage(`Unknown Host Address.`);
405
391
  }
406
- this.LogEx(`Server starting with ${numCPUs} Cores/Threads`);
392
+ this.LogInfoMessage(`Server starting with ${numCPUs} Cores/Threads`);
407
393
 
408
- this.LogEx(`Hostname: ${hostname}`);
409
- this.LogEx(`System: ${JSON.stringify(sysinfo.system)}`);
410
- this.LogEx(`OS Info: ${JSON.stringify(sysinfo.osInfo)}`);
411
- this.LogEx(`CPU: ${JSON.stringify(sysinfo.cpu)}`);
412
- this.LogEx(`Memory: ${JSON.stringify(sysinfo.mem)}`);
394
+ this.LogInfoMessage(`Hostname: ${hostname}`);
395
+ this.LogInfoMessage(`System: ${JSON.stringify(sysinfo.system)}`);
396
+ this.LogInfoMessage(`OS Info: ${JSON.stringify(sysinfo.osInfo)}`);
397
+ this.LogInfoMessage(`CPU: ${JSON.stringify(sysinfo.cpu)}`);
398
+ this.LogInfoMessage(`Memory: ${JSON.stringify(sysinfo.mem)}`);
413
399
  }
414
400
 
415
401
  GetSignalColour = (signal: any) => {
@@ -167,36 +167,35 @@ export class ServerProcessBase extends ProcessBase
167
167
 
168
168
  if (this.options.clusterMode) {
169
169
  if (this.options.useRedisAdaptor) {
170
- this.LogEx(`Using Redis for socket.io cluster management (worker)`);
170
+ this.LogInfoMessage(`Using Redis for socket.io cluster management (worker)`);
171
171
  if (this.options.redisAdaptorUrl) {
172
- this.LogEx(`Redis url: [${this.options.redisAdaptorUrl}]`);
172
+ this.LogInfoMessage(`Redis url: [${this.options.redisAdaptorUrl}]`);
173
173
  this.#redisClient = createClient({url: this.options.redisAdaptorUrl});
174
174
  } else {
175
- this.LogEx(`Redis url: [localhost]`);
175
+ this.LogInfoMessage(`Redis url: [localhost]`);
176
176
  this.#redisClient = createClient();
177
177
  }
178
178
  await this.#redisClient.connect();
179
179
  this.#io.adapter(createAdapter(this.#redisClient) as any);
180
- this.LogEx(`Redis successfully connected.`);
180
+ this.LogInfoMessage(`Redis successfully connected.`);
181
181
  } else {
182
182
  this.#io.adapter(clusterCreateAdapter() as any);
183
- this.LogEx(`Using nodejs cluster mode for socket.io cluster management`);
183
+ this.LogInfoMessage(`Using nodejs cluster mode for socket.io cluster management`);
184
184
  }
185
185
  } else {
186
- this.LogEx(`Not using any adaptors for socket.io cluster management.}`);
186
+ this.LogInfoMessage(`Not using any adaptors for socket.io cluster management.}`);
187
187
  }
188
188
 
189
189
  // To use a seperate socket server, the code below can be applied.
190
190
  // this.#io = require("socket.io")(options);
191
191
  // this.#io.adapter(createAdapter());
192
192
  // this.#io.listen(3006);
193
- // LogEx(`socket.io init`);
194
193
 
195
194
  this.#io.engine.on("connection_error", (err) => {
196
- this.LogEx(err.req); // the request object
197
- this.LogEx(err.code); // the error code, for example 1
198
- this.LogEx(err.message); // the error message, for example "Session ID unknown"
199
- this.LogEx(err.context); // some additional error context
195
+ this.LogInfoMessage(err.req); // the request object
196
+ this.LogInfoMessage(err.code); // the error code, for example 1
197
+ this.LogInfoMessage(err.message); // the error message, for example "Session ID unknown"
198
+ this.LogInfoMessage(err.context); // some additional error context
200
199
  });
201
200
  }
202
201
 
@@ -226,7 +225,7 @@ export class ServerProcessBase extends ProcessBase
226
225
  //@@chmodSync(this.options.port, 511);
227
226
  }).on('listening', () =>
228
227
  {
229
- this.LogEx(`live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
228
+ this.LogInfoMessage(`live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
230
229
  });
231
230
  }
232
231
 
@@ -237,7 +236,7 @@ export class ServerProcessBase extends ProcessBase
237
236
  this.LogInfoMessage('TCP Server is running on port ' + this.options.listenPort + '.');
238
237
  }).on('listening', () =>
239
238
  {
240
- this.LogEx(`TCP live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
239
+ this.LogInfoMessage(`TCP live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
241
240
  });
242
241
  }
243
242
 
@@ -253,7 +252,7 @@ export class ServerProcessBase extends ProcessBase
253
252
  this.LogInfoMessage('JSON RPC 2.0 Server is running on port ' + this.options.listenPort + '.');
254
253
  }).on('listening', () =>
255
254
  {
256
- this.LogEx(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
255
+ this.LogInfoMessage(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
257
256
  });
258
257
  }
259
258
 
@@ -283,20 +282,20 @@ export class ServerProcessBase extends ProcessBase
283
282
  if (!this.options.clusterMode) {
284
283
  if (this.GetUIController() !== null)
285
284
  {
286
- this.LogEx('Destroy the user interface controller.');
285
+ this.LogInfoMessage('Destroy the user interface controller.');
287
286
  this.GetUIController().DestroyUI();
288
287
  }
289
288
 
290
289
  if (signal) {
291
- this.LogEx(this.GetSignalColour(signal)(`Main Process (singleprocess): ${process.pid} received signal: ${signal}`));
290
+ this.LogInfoMessage(this.GetSignalColour(signal)(`Main Process (singleprocess): ${process.pid} received signal: ${signal}`));
292
291
  } else {
293
- this.LogEx(this.GetSignalColour(null)(`Main Process (singleprocess): ${process.pid} received Terminate without signal.`));
292
+ this.LogInfoMessage(this.GetSignalColour(null)(`Main Process (singleprocess): ${process.pid} received Terminate without signal.`));
294
293
  }
295
294
  }
296
295
 
297
296
  if (this.options.wssServer === true && this.#io !== null)
298
297
  {
299
- this.LogEx(`Disconnect Sockets.`);
298
+ this.LogInfoMessage(`Disconnect Sockets.`);
300
299
  if (this.socketIoServerHelper !== null) {
301
300
  this.socketIoServerHelper.DisconnectSockets();
302
301
  } else {
@@ -310,33 +309,33 @@ export class ServerProcessBase extends ProcessBase
310
309
  if (this.#httpServer) {
311
310
  if (this.options.serverType === STSServerType.TCPRAW_TLS) {
312
311
  this.#sockets.forEach((socket: net.Socket, index, array) => {
313
- this.LogEx(chalk.yellow(`TCP Socket destroy, remote address: [${socket.remoteAddress}], remote port: [${socket.remotePort}]`));
312
+ this.LogInfoMessage(chalk.yellow(`TCP Socket destroy, remote address: [${socket.remoteAddress}], remote port: [${socket.remotePort}]`));
314
313
  socket.destroy();
315
314
  //socket.end();
316
315
  });
317
316
  }
318
- this.LogEx(`Closing httpServer.`);
317
+ this.LogInfoMessage(`Closing httpServer.`);
319
318
  await this.#httpServer.close();
320
319
  }
321
320
 
322
321
  if (this.options.useDatabase) {
323
- this.LogEx(`Ending database connections and pools.`);
322
+ this.LogInfoMessage(`Ending database connections and pools.`);
324
323
  await this.TerminateDatabase();
325
324
  //await this.accessLayer.enddatabase();
326
325
  }
327
326
 
328
327
  if (this.options.clusterMode) {
329
- this.LogEx(`Performing exit value: [${clusterPerformExit}]`);
328
+ this.LogInfoMessage(`Performing exit value: [${clusterPerformExit}]`);
330
329
  if (clusterPerformExit) {
331
- this.LogEx(`Process will self terminate with process.exit(0).`);
330
+ this.LogInfoMessage(`Process will self terminate with process.exit(0).`);
332
331
  } else {
333
- this.LogEx(`Child process will not self terminate. Terminate will be handled by master process.`);
332
+ this.LogInfoMessage(`Child process will not self terminate. Terminate will be handled by master process.`);
334
333
  }
335
334
  }
336
335
 
337
336
  //if (this.InstrumentController && this.InstrumentController.Workers.length > 0) {
338
337
  if (this.InstrumentController) {
339
- this.LogEx(`Ending publisher.`);
338
+ this.LogInfoMessage(`Ending publisher.`);
340
339
  setTimeout(() => {
341
340
  //if (this.InstrumentController && this.InstrumentController.Workers.length > 0) {
342
341
  if (this.InstrumentController) {
@@ -362,15 +361,15 @@ export class ServerProcessBase extends ProcessBase
362
361
  } else {
363
362
  if (this.options.processExitOnTerminate && this.options.processExitOnTerminate === true) {
364
363
  setTimeout(() => {
365
- this.LogEx(`Performing process.exit(0).`);
364
+ this.LogInfoMessage(`Performing process.exit(0).`);
366
365
  process.exit(0);
367
366
  }, this.#masterProcessExitTime); // Give the workers time to terminate gracefully
368
367
  } else {
369
- this.LogEx(`Performing process.exit(0) - Immediate.`);
368
+ this.LogInfoMessage(`Performing process.exit(0) - Immediate.`);
370
369
  }
371
370
  }
372
371
  } else {
373
- this.LogEx(`Process already terminating.`);
372
+ this.LogInfoMessage(`Process already terminating.`);
374
373
  }
375
374
  }
376
375
 
@@ -91,8 +91,8 @@ export class SingleProcessBase extends ServerProcessBase implements ISingleProce
91
91
  this.expressServer = new STSExpressServer(this.options, this);
92
92
  }
93
93
 
94
- this.LogEx(`Service instance starting. Instance Id: [${this.options.serviceInstanceId}]`);
95
- this.LogEx(`Master process:${process.pid} started`);
94
+ this.LogInfoMessage(`Service instance starting. Instance Id: [${this.options.serviceInstanceId}]`);
95
+ this.LogInfoMessage(`Master process:${process.pid} started`);
96
96
 
97
97
  this.LogSystemTelemetry();
98
98
 
@@ -106,9 +106,9 @@ export class SingleProcessBase extends ServerProcessBase implements ISingleProce
106
106
 
107
107
  process.on('exit', (code) => {
108
108
  if (code === 0) {
109
- this.LogEx(chalk.green(`Main Process: ${process.pid} terminated gracefully with code: ${code}`));
109
+ this.LogInfoMessage(chalk.green(`Main Process: ${process.pid} terminated gracefully with code: ${code}`));
110
110
  } else {
111
- this.LogEx(chalk.red(`Main Process: ${process.pid} terminated with code: ${code}`));
111
+ this.LogInfoMessage(chalk.red(`Main Process: ${process.pid} terminated with code: ${code}`));
112
112
  }
113
113
  });
114
114
 
@@ -116,7 +116,7 @@ export class SingleProcessBase extends ServerProcessBase implements ISingleProce
116
116
 
117
117
  this.ProcessStarted();
118
118
 
119
- this.LogEx(chalk.green(`Main process:${process.pid} started`));
119
+ this.LogInfoMessage(chalk.green(`Main process:${process.pid} started`));
120
120
  }
121
121
 
122
122
  async TerminateApplication()
@@ -307,7 +307,7 @@ export class AppMaster extends MasterProcessBase
307
307
  this.#LogInfoMessage('JSON RPC 2.0 Server is running on port ' + this.options.listenPort + '.');
308
308
  }).on('listening', () =>
309
309
  {
310
- this.LogEx(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
310
+ this.LogInfoMessage(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
311
311
  });
312
312
  return server;
313
313
  }
@@ -512,13 +512,13 @@ export class AppMaster extends MasterProcessBase
512
512
  }
513
513
 
514
514
  #StartRAFTService = async () => {
515
- this.LogEx(chalk.green(`---[ RAFT Protocol Starting ]---`));
515
+ this.LogInfoMessage(chalk.green(`---[ RAFT Protocol Starting ]---`));
516
516
  this.#server = await this.#SetupJSONRPCServer();
517
517
  this.#StartElectionTimeout();
518
518
  }
519
519
 
520
520
  #ChangeState(newState: AppMasterRAFTState) {
521
- this.LogEx(chalk.magenta(`${this.#GetLogPrefix()}: State Change, From: [${this.#RAFTState.toString()}] --> To: [${newState.toString()}]`));
521
+ this.LogInfoMessage(chalk.magenta(`${this.#GetLogPrefix()}: State Change, From: [${this.#RAFTState.toString()}] --> To: [${newState.toString()}]`));
522
522
  this.#RAFTState = newState;
523
523
  }
524
524
 
@@ -129,7 +129,7 @@ export class WorkerProcessBase extends ServerProcessBase implements IWorkerProce
129
129
  this.expressServer = new STSExpressServer(this.options, this);
130
130
  }
131
131
 
132
- this.LogEx(`Worker instance starting. Service instance Id: [${this.options.serviceInstanceId}]`);
132
+ this.LogInfoMessage(`Worker instance starting. Service instance Id: [${this.options.serviceInstanceId}]`);
133
133
 
134
134
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
135
  process.on('message', async (msg: any) => {
@@ -153,15 +153,15 @@ export class WorkerProcessBase extends ServerProcessBase implements IWorkerProce
153
153
  switch (msg.command)
154
154
  {
155
155
  case 'Terminate' :
156
- this.LogEx(chalk.grey(`Received ` + chalk.bold.italic(`Terminate`) + ` message from master thread`));
156
+ this.LogInfoMessage(chalk.grey(`Received ` + chalk.bold.italic(`Terminate`) + ` message from master thread`));
157
157
  await this.Terminate(true, false); // Don't kill the child process here, the master will take care of that ...
158
158
  break;
159
159
  case 'TerminateAndKill' :
160
- this.LogEx(chalk.grey(`Received ` + chalk.bold.italic(`Terminate`) + ` message from master thread`));
160
+ this.LogInfoMessage(chalk.grey(`Received ` + chalk.bold.italic(`Terminate`) + ` message from master thread`));
161
161
  await this.Terminate(true, true);
162
162
  break;
163
163
  case 'Message' :
164
- //this.LogEx(chalk.grey(`Received ` + chalk.bold.italic(`Message`) + ` message from master thread`));
164
+ //this.LogInfoMessage(chalk.grey(`Received ` + chalk.bold.italic(`Message`) + ` message from master thread`));
165
165
  this.ReceivedMessageFromMaster(msg.data);
166
166
  break;
167
167
  case 'Response' : // General response to a req/response interaction
@@ -174,13 +174,13 @@ export class WorkerProcessBase extends ServerProcessBase implements IWorkerProce
174
174
  // https://en.wikipedia.org/wiki/Signal_(IPC)
175
175
  process.on('SIGTERM', async () =>
176
176
  {
177
- this.LogEx(`SIGTERM signal received for worker: ${process.pid}`);
177
+ this.LogInfoMessage(`SIGTERM signal received for worker: ${process.pid}`);
178
178
  await this.Terminate(true, true);
179
179
  });
180
180
 
181
181
  process.on('SIGINT', async () =>
182
182
  {
183
- this.LogEx(`SIGINT signal received for worker: ${process.pid}`);
183
+ this.LogInfoMessage(`SIGINT signal received for worker: ${process.pid}`);
184
184
  await this.Terminate(true, true);
185
185
  });
186
186
 
@@ -188,6 +188,6 @@ export class WorkerProcessBase extends ServerProcessBase implements IWorkerProce
188
188
 
189
189
  this.WorkerStarted();
190
190
 
191
- this.LogEx(chalk.green(`Worker process:${process.pid} started`));
191
+ this.LogInfoMessage(chalk.green(`Worker process:${process.pid} started`));
192
192
  };
193
193
  }
@@ -31,7 +31,6 @@ export interface IProcessBase extends STSOptionsBase {
31
31
  ProcessStartup: () => void;
32
32
  UpdateInstrument: (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry) => void;
33
33
  get InstrumentController(): PublishInstrumentControllerV2 | null;
34
- LogEx: (message: any) => void;
35
34
  LogErrorMessage(message: any): void;
36
35
  LogInfoMessage(message: any): void;
37
36
  LogMessageToLoggerInstrument(message: any): void;