@smythos/sre 1.7.5 → 1.7.7

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.
@@ -18,7 +18,8 @@ import { CodeConnector } from '@sre/ComputeManager/Code.service/CodeConnector';
18
18
  import { SchedulerConnector } from '@sre/AgentManager/Scheduler.service/SchedulerConnector';
19
19
  export declare class ConnectorService {
20
20
  static Connectors: {};
21
- static ConnectorInstances: any;
21
+ protected static _instances: any;
22
+ static get ConnectorInstances(): any;
22
23
  static get ready(): boolean;
23
24
  static get service(): TServiceRegistry;
24
25
  /**
@@ -25,5 +25,6 @@ export declare class SmythRuntime {
25
25
  ready(): Promise<boolean>;
26
26
  private _stopping;
27
27
  _stop(): Promise<void>;
28
+ private setupShutdownHandlers;
28
29
  }
29
30
  export declare const SRE: SmythRuntime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smythos/sre",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "description": "Smyth Runtime Environment",
5
5
  "author": "Alaa-eddine KADDOURI",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@ import { ModelsProviderConnector } from '@sre/LLMManager/ModelsProvider.service/
21
21
  import { CodeConnector } from '@sre/ComputeManager/Code.service/CodeConnector';
22
22
  import { SchedulerConnector } from '@sre/AgentManager/Scheduler.service/SchedulerConnector';
23
23
  const console = Logger('ConnectorService');
24
-
24
+ const SRE_CONNECTORS_GLOBAL_KEY = Symbol.for('SRE:ConnectorInstances');
25
25
  let ServiceRegistry: TServiceRegistry = {};
26
26
  let _ready = false;
27
27
  SystemEvents.on('SRE:Booted', (services) => {
@@ -31,7 +31,17 @@ SystemEvents.on('SRE:Booted', (services) => {
31
31
  export class ConnectorService {
32
32
  public static Connectors = {};
33
33
 
34
- public static ConnectorInstances: any = {};
34
+ protected static _instances: any = {};
35
+
36
+ public static get ConnectorInstances() {
37
+ if (global[SRE_CONNECTORS_GLOBAL_KEY]) {
38
+ return global[SRE_CONNECTORS_GLOBAL_KEY];
39
+ }
40
+ ConnectorService._instances = {};
41
+ global[SRE_CONNECTORS_GLOBAL_KEY] = ConnectorService._instances;
42
+ return ConnectorService._instances;
43
+ }
44
+ //public static ConnectorInstances: any = {};
35
45
  public static get ready() {
36
46
  return _ready;
37
47
  }
@@ -9,7 +9,7 @@ import pkg from '../../package.json';
9
9
 
10
10
  const logger = Logger('SRE');
11
11
 
12
- const SRE_GLOBAL_KEY = Symbol.for('SRE@singleton');
12
+ const SRE_GLOBAL_KEY = Symbol.for('SRE:Instance');
13
13
 
14
14
  export class SmythRuntime {
15
15
  public started = false;
@@ -150,6 +150,8 @@ export class SmythRuntime {
150
150
  this._initialized = true;
151
151
  SystemEvents.emit('SRE:Initialized', SmythRuntime.Instance);
152
152
 
153
+ this.setupShutdownHandlers();
154
+
153
155
  return SmythRuntime.Instance as SmythRuntime;
154
156
  }
155
157
 
@@ -219,6 +221,23 @@ export class SmythRuntime {
219
221
  SmythRuntime.instance = undefined;
220
222
  this.started = false;
221
223
  }
224
+
225
+ private setupShutdownHandlers() {
226
+ ['SIGINT', 'SIGTERM'].forEach((signal) => {
227
+ process.on(signal, async () => {
228
+ await shutdown(signal);
229
+ process.exit(0); // Required after async
230
+ });
231
+ });
232
+
233
+ process.on('beforeExit', (code) => {
234
+ shutdown('beforeExit');
235
+ });
236
+
237
+ process.on('exit', (code) => {
238
+ logger.info(`Goodbye!`);
239
+ });
240
+ }
222
241
  }
223
242
 
224
243
  export const SRE = SmythRuntime.Instance;
@@ -239,21 +258,6 @@ async function shutdown(reason) {
239
258
  }
240
259
  }
241
260
 
242
- ['SIGINT', 'SIGTERM'].forEach((signal) => {
243
- process.on(signal, async () => {
244
- await shutdown(signal);
245
- process.exit(0); // Required after async
246
- });
247
- });
248
-
249
- process.on('beforeExit', (code) => {
250
- shutdown('beforeExit');
251
- });
252
-
253
- process.on('exit', (code) => {
254
- logger.info(`Goodbye!`);
255
- });
256
-
257
261
  // process.on('uncaughtException', (err) => {
258
262
 
259
263
  // });