@kapeta/local-cluster-service 0.54.9 → 0.54.10

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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [0.54.10](https://github.com/kapetacom/local-cluster-service/compare/v0.54.9...v0.54.10) (2024-07-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * make instanceManager watch explicit w/ start+stop ([ff86ca7](https://github.com/kapetacom/local-cluster-service/commit/ff86ca7c9077a5901c3578a6920298ba6bfb21e3))
7
+ * make repositoryManager watch explicit w/ start+stop in index ([f7c08e7](https://github.com/kapetacom/local-cluster-service/commit/f7c08e70947a185cfb8e8ca4e83183af297d85aa))
8
+ * send QA and Building events ([955d171](https://github.com/kapetacom/local-cluster-service/commit/955d17128aed1f51ded68d723e10c501d0000696))
9
+ * temporarily disable code verify and fixing while codegen is unstable ([08e54b6](https://github.com/kapetacom/local-cluster-service/commit/08e54b61bdab402a84370d985e5d25d2fa9f9588))
10
+
1
11
  ## [0.54.9](https://github.com/kapetacom/local-cluster-service/compare/v0.54.8...v0.54.9) (2024-07-02)
2
12
 
3
13
 
package/dist/cjs/index.js CHANGED
@@ -61,6 +61,7 @@ const authManager_1 = require("./src/authManager");
61
61
  const codeGeneratorManager_1 = require("./src/codeGeneratorManager");
62
62
  const Sentry = __importStar(require("@sentry/node"));
63
63
  const assetManager_1 = require("./src/assetManager");
64
+ const instanceManager_1 = require("./src/instanceManager");
64
65
  Sentry.init({
65
66
  dsn: 'https://0b7cc946d82c591473d6f95fff5e210b@o4505820837249024.ingest.sentry.io/4506212692000768',
66
67
  enabled: process.env.NODE_ENV !== 'development',
@@ -191,6 +192,8 @@ exports.default = {
191
192
  }
192
193
  await clusterService_1.clusterService.init();
193
194
  authManager_1.authManager.listenForChanges();
195
+ instanceManager_1.instanceManager.startMonitoring();
196
+ repositoryManager_1.repositoryManager.listenForChanges();
194
197
  currentServer = createServer();
195
198
  const port = clusterService_1.clusterService.getClusterServicePort();
196
199
  const host = clusterService_1.clusterService.getClusterServiceHost();
@@ -250,7 +253,9 @@ exports.default = {
250
253
  * Stops any currently running cluster services.
251
254
  * @return {Promise<boolean>} Returns true if the service was stopped - false if no service was running.
252
255
  */
253
- stop: function () {
256
+ stop: async function () {
257
+ instanceManager_1.instanceManager.stopMonitoring();
258
+ await repositoryManager_1.repositoryManager.stopListening();
254
259
  if (currentServer) {
255
260
  return new Promise(function (resolve) {
256
261
  if (currentServer) {
@@ -10,6 +10,8 @@ export declare class InstanceManager {
10
10
  private readonly _instances;
11
11
  private readonly instanceLocks;
12
12
  constructor();
13
+ startMonitoring(): void;
14
+ stopMonitoring(): void;
13
15
  private checkInstancesLater;
14
16
  getInstances(): InstanceInfo[];
15
17
  getInstancesForPlan(systemId: string): Promise<InstanceInfo[]>;
@@ -32,9 +32,16 @@ class InstanceManager {
32
32
  instanceLocks = new async_lock_1.default();
33
33
  constructor() {
34
34
  this._instances = storageService_1.storageService.section('instances', []);
35
+ }
36
+ startMonitoring() {
35
37
  // We need to wait a bit before running the first check
36
38
  this.checkInstancesLater(1000);
37
39
  }
40
+ stopMonitoring() {
41
+ if (this._interval) {
42
+ clearTimeout(this._interval);
43
+ }
44
+ }
38
45
  checkInstancesLater(time = CHECK_INTERVAL) {
39
46
  if (this._interval) {
40
47
  clearTimeout(this._interval);
@@ -42,7 +42,6 @@ class RepositoryManager extends node_events_1.EventEmitter {
42
42
  super();
43
43
  this._registryService = new nodejs_registry_utils_1.RegistryService(nodejs_registry_utils_1.Config.data.registry.url);
44
44
  this.watcher = new RepositoryWatcher_1.RepositoryWatcher();
45
- this.listenForChanges();
46
45
  this.watcher.on('change', (file, source) => {
47
46
  this.emit('change', file, source);
48
47
  });
@@ -390,10 +390,12 @@ class StormCodegen {
390
390
  await (0, promises_1.writeFile)(kapetaYmlPath, kapetaYaml);
391
391
  const blockRef = block.uri;
392
392
  this.emitBlockStatus(blockUri, block.aiName, events_1.StormEventBlockStatusType.QA);
393
- const filesToBeFixed = serviceFiles.concat(contextFiles).concat(screenFilesConverted);
394
- const codeGenerator = new codegen_1.BlockCodeGenerator(blockDefinition);
393
+ /* TODO: temporarily disabled - enable again when codegen is more stable
394
+ const filesToBeFixed = serviceFiles.concat(contextFiles).concat(screenFilesConverted);
395
+ const codeGenerator = new BlockCodeGenerator(blockDefinition);
396
+ */
395
397
  this.emitBlockStatus(blockUri, block.aiName, events_1.StormEventBlockStatusType.BUILDING);
396
- await this.verifyAndFixCode(blockUri, block.aiName, codeGenerator, basePath, filesToBeFixed, allFiles);
398
+ // await this.verifyAndFixCode(blockUri, block.aiName, codeGenerator, basePath, filesToBeFixed, allFiles);
397
399
  this.out.emit('data', {
398
400
  type: 'BLOCK_READY',
399
401
  reason: 'Block ready',
package/dist/esm/index.js CHANGED
@@ -61,6 +61,7 @@ const authManager_1 = require("./src/authManager");
61
61
  const codeGeneratorManager_1 = require("./src/codeGeneratorManager");
62
62
  const Sentry = __importStar(require("@sentry/node"));
63
63
  const assetManager_1 = require("./src/assetManager");
64
+ const instanceManager_1 = require("./src/instanceManager");
64
65
  Sentry.init({
65
66
  dsn: 'https://0b7cc946d82c591473d6f95fff5e210b@o4505820837249024.ingest.sentry.io/4506212692000768',
66
67
  enabled: process.env.NODE_ENV !== 'development',
@@ -191,6 +192,8 @@ exports.default = {
191
192
  }
192
193
  await clusterService_1.clusterService.init();
193
194
  authManager_1.authManager.listenForChanges();
195
+ instanceManager_1.instanceManager.startMonitoring();
196
+ repositoryManager_1.repositoryManager.listenForChanges();
194
197
  currentServer = createServer();
195
198
  const port = clusterService_1.clusterService.getClusterServicePort();
196
199
  const host = clusterService_1.clusterService.getClusterServiceHost();
@@ -250,7 +253,9 @@ exports.default = {
250
253
  * Stops any currently running cluster services.
251
254
  * @return {Promise<boolean>} Returns true if the service was stopped - false if no service was running.
252
255
  */
253
- stop: function () {
256
+ stop: async function () {
257
+ instanceManager_1.instanceManager.stopMonitoring();
258
+ await repositoryManager_1.repositoryManager.stopListening();
254
259
  if (currentServer) {
255
260
  return new Promise(function (resolve) {
256
261
  if (currentServer) {
@@ -10,6 +10,8 @@ export declare class InstanceManager {
10
10
  private readonly _instances;
11
11
  private readonly instanceLocks;
12
12
  constructor();
13
+ startMonitoring(): void;
14
+ stopMonitoring(): void;
13
15
  private checkInstancesLater;
14
16
  getInstances(): InstanceInfo[];
15
17
  getInstancesForPlan(systemId: string): Promise<InstanceInfo[]>;
@@ -32,9 +32,16 @@ class InstanceManager {
32
32
  instanceLocks = new async_lock_1.default();
33
33
  constructor() {
34
34
  this._instances = storageService_1.storageService.section('instances', []);
35
+ }
36
+ startMonitoring() {
35
37
  // We need to wait a bit before running the first check
36
38
  this.checkInstancesLater(1000);
37
39
  }
40
+ stopMonitoring() {
41
+ if (this._interval) {
42
+ clearTimeout(this._interval);
43
+ }
44
+ }
38
45
  checkInstancesLater(time = CHECK_INTERVAL) {
39
46
  if (this._interval) {
40
47
  clearTimeout(this._interval);
@@ -42,7 +42,6 @@ class RepositoryManager extends node_events_1.EventEmitter {
42
42
  super();
43
43
  this._registryService = new nodejs_registry_utils_1.RegistryService(nodejs_registry_utils_1.Config.data.registry.url);
44
44
  this.watcher = new RepositoryWatcher_1.RepositoryWatcher();
45
- this.listenForChanges();
46
45
  this.watcher.on('change', (file, source) => {
47
46
  this.emit('change', file, source);
48
47
  });
@@ -390,10 +390,12 @@ class StormCodegen {
390
390
  await (0, promises_1.writeFile)(kapetaYmlPath, kapetaYaml);
391
391
  const blockRef = block.uri;
392
392
  this.emitBlockStatus(blockUri, block.aiName, events_1.StormEventBlockStatusType.QA);
393
- const filesToBeFixed = serviceFiles.concat(contextFiles).concat(screenFilesConverted);
394
- const codeGenerator = new codegen_1.BlockCodeGenerator(blockDefinition);
393
+ /* TODO: temporarily disabled - enable again when codegen is more stable
394
+ const filesToBeFixed = serviceFiles.concat(contextFiles).concat(screenFilesConverted);
395
+ const codeGenerator = new BlockCodeGenerator(blockDefinition);
396
+ */
395
397
  this.emitBlockStatus(blockUri, block.aiName, events_1.StormEventBlockStatusType.BUILDING);
396
- await this.verifyAndFixCode(blockUri, block.aiName, codeGenerator, basePath, filesToBeFixed, allFiles);
398
+ // await this.verifyAndFixCode(blockUri, block.aiName, codeGenerator, basePath, filesToBeFixed, allFiles);
397
399
  this.out.emit('data', {
398
400
  type: 'BLOCK_READY',
399
401
  reason: 'Block ready',
package/index.ts CHANGED
@@ -35,6 +35,7 @@ import { authManager } from './src/authManager';
35
35
  import { codeGeneratorManager } from './src/codeGeneratorManager';
36
36
  import * as Sentry from '@sentry/node';
37
37
  import { assetManager } from './src/assetManager';
38
+ import { instanceManager } from './src/instanceManager';
38
39
 
39
40
  Sentry.init({
40
41
  dsn: 'https://0b7cc946d82c591473d6f95fff5e210b@o4505820837249024.ingest.sentry.io/4506212692000768',
@@ -197,6 +198,8 @@ export default {
197
198
  await clusterService.init();
198
199
 
199
200
  authManager.listenForChanges();
201
+ instanceManager.startMonitoring();
202
+ repositoryManager.listenForChanges();
200
203
 
201
204
  currentServer = createServer();
202
205
 
@@ -266,7 +269,9 @@ export default {
266
269
  * Stops any currently running cluster services.
267
270
  * @return {Promise<boolean>} Returns true if the service was stopped - false if no service was running.
268
271
  */
269
- stop: function () {
272
+ stop: async function () {
273
+ instanceManager.stopMonitoring();
274
+ await repositoryManager.stopListening();
270
275
  if (currentServer) {
271
276
  return new Promise(function (resolve) {
272
277
  if (currentServer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.54.9",
3
+ "version": "0.54.10",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -49,7 +49,7 @@ const DEFAULT_HEALTH_PORT_TYPE = 'http';
49
49
  const MIN_TIME_RUNNING = 30000; //If something didnt run for more than 30 secs - it failed
50
50
 
51
51
  export class InstanceManager {
52
- private _interval: any = undefined;
52
+ private _interval: ReturnType<typeof setTimeout> | undefined = undefined;
53
53
 
54
54
  private readonly _instances: InstanceInfo[] = [];
55
55
 
@@ -57,11 +57,19 @@ export class InstanceManager {
57
57
 
58
58
  constructor() {
59
59
  this._instances = storageService.section('instances', []);
60
+ }
60
61
 
62
+ public startMonitoring() {
61
63
  // We need to wait a bit before running the first check
62
64
  this.checkInstancesLater(1000);
63
65
  }
64
66
 
67
+ public stopMonitoring() {
68
+ if (this._interval) {
69
+ clearTimeout(this._interval);
70
+ }
71
+ }
72
+
65
73
  private checkInstancesLater(time = CHECK_INTERVAL) {
66
74
  if (this._interval) {
67
75
  clearTimeout(this._interval);
@@ -43,7 +43,6 @@ class RepositoryManager extends EventEmitter {
43
43
  super();
44
44
  this._registryService = new RegistryService(Config.data.registry.url);
45
45
  this.watcher = new RepositoryWatcher();
46
- this.listenForChanges();
47
46
 
48
47
  this.watcher.on('change', (file: string, source: SourceOfChange) => {
49
48
  this.emit('change', file, source);
@@ -480,11 +480,13 @@ export class StormCodegen {
480
480
 
481
481
  this.emitBlockStatus(blockUri, block.aiName, StormEventBlockStatusType.QA);
482
482
 
483
- const filesToBeFixed = serviceFiles.concat(contextFiles).concat(screenFilesConverted);
484
- const codeGenerator = new BlockCodeGenerator(blockDefinition);
483
+ /* TODO: temporarily disabled - enable again when codegen is more stable
484
+ const filesToBeFixed = serviceFiles.concat(contextFiles).concat(screenFilesConverted);
485
+ const codeGenerator = new BlockCodeGenerator(blockDefinition);
486
+ */
485
487
 
486
488
  this.emitBlockStatus(blockUri, block.aiName, StormEventBlockStatusType.BUILDING);
487
- await this.verifyAndFixCode(blockUri, block.aiName, codeGenerator, basePath, filesToBeFixed, allFiles);
489
+ // await this.verifyAndFixCode(blockUri, block.aiName, codeGenerator, basePath, filesToBeFixed, allFiles);
488
490
 
489
491
  this.out.emit('data', {
490
492
  type: 'BLOCK_READY',