@kumologica/sdk 3.6.4-beta4 → 3.6.4-beta5

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.
@@ -87,10 +87,7 @@ exports.handler = async ({ project_directory, loglevel, port, taskName, args })
87
87
  };
88
88
 
89
89
  // Start a server
90
- let server = new TaskServer({
91
- flowPath: projectFlowFullPath,
92
- cliParams,
93
- });
90
+ let server = new TaskServer(projectFlowFullPath, cliParams);
94
91
 
95
92
  await server.listen();
96
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumologica/sdk",
3
- "version": "3.6.4-beta4",
3
+ "version": "3.6.4-beta5",
4
4
  "productName": "Kumologica Designer",
5
5
  "copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
6
6
  "author": "Kumologica Pty Ltd <contact@kumologica.com>",
@@ -83,9 +83,9 @@
83
83
  "@aws-sdk/credential-providers": "^3.556.0",
84
84
  "@aws-sdk/lib-dynamodb": "^3.549.0",
85
85
  "@electron/remote": "^2.0.8",
86
- "@kumologica/builder": "3.6.4-beta4",
87
- "@kumologica/devkit": "3.6.4-beta4",
88
- "@kumologica/runtime": "3.6.4-beta4",
86
+ "@kumologica/builder": "3.6.4-beta5",
87
+ "@kumologica/devkit": "3.6.4-beta5",
88
+ "@kumologica/runtime": "3.6.4-beta5",
89
89
  "ajv": "8.10.0",
90
90
  "archive-type": "^4.0.0",
91
91
  "basic-auth": "2.0.1",
@@ -5,6 +5,7 @@ const {
5
5
  PLATFORMS,
6
6
  } = require("@kumologica/runtime");
7
7
 
8
+ const tcpPortUsed = require("tcp-port-used");
8
9
 
9
10
  /**
10
11
  * This class will encapsulate the adminApp and FlowApp into two servers.
@@ -32,12 +33,26 @@ class TaskServer {
32
33
  { noadmin: true }
33
34
  );
34
35
 
35
- this.config = { ...baseConfig, ...params };
36
+ this.config = { ...baseConfig, ...params };
36
37
 
37
- this.flowServer = new AbstractServerfulServer(this.config);
38
+ console.log(`Runtime configuration:${JSON.stringify(this.config)}`);
38
39
  }
39
40
 
41
+ async allocatePort(port) {
42
+ let inUse = await tcpPortUsed.check(port);
43
+ if (inUse) {
44
+ let newPort = port + 1;
45
+ console.log(`> Port: ${port} in use. Trying with port: ${newPort}...`);
46
+ return await this.allocatePort(newPort);
47
+ } else {
48
+ return port;
49
+ }
50
+ }
51
+
40
52
  async listen() {
53
+ this.config.port = await this.allocatePort(this.config.port || 1880);
54
+ this.flowServer = new AbstractServerfulServer(this.config);
55
+
41
56
  await this.flowServer.start();
42
57
  this.flowServer.log.debug(`Runtime configuration:${JSON.stringify(this.config)}`);
43
58
  }