@kapeta/local-cluster-service 0.0.76 → 0.1.1
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 +14 -0
- package/definitions.d.ts +4 -4
- package/index.js +2 -2
- package/package.json +2 -3
- package/src/assetManager.js +4 -2
- package/src/containerManager.js +288 -243
- package/src/instanceManager.js +33 -9
- package/src/instances/routes.js +10 -0
- package/src/networkManager.js +6 -6
- package/src/proxy/routes.js +16 -14
- package/src/proxy/types/rest.js +5 -6
- package/src/proxy/types/web.js +3 -5
- package/src/repositoryManager.js +16 -5
- package/src/serviceManager.js +0 -1
- package/src/utils/BlockInstanceRunner.js +435 -0
- package/src/utils/LogData.js +50 -0
- package/src/utils/utils.js +13 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
const MAX_LINES = 1000;
|
2
|
+
|
3
|
+
class LogData {
|
4
|
+
|
5
|
+
constructor() {
|
6
|
+
/**
|
7
|
+
*
|
8
|
+
* @type {LogEntry[]}
|
9
|
+
*/
|
10
|
+
this.entries = [];
|
11
|
+
}
|
12
|
+
|
13
|
+
/**
|
14
|
+
*
|
15
|
+
* @param {string} msg
|
16
|
+
* @param {string} [level]
|
17
|
+
* @param {string} [source]
|
18
|
+
*/
|
19
|
+
addLog(msg, level = 'INFO', source = 'STDOUT') {
|
20
|
+
while(this.entries.length > MAX_LINES) {
|
21
|
+
this.entries.shift();
|
22
|
+
}
|
23
|
+
|
24
|
+
if (!msg.endsWith('\n')) {
|
25
|
+
msg += '\n';
|
26
|
+
}
|
27
|
+
this.entries.push({
|
28
|
+
time: Date.now(),
|
29
|
+
message: msg,
|
30
|
+
level,
|
31
|
+
source
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
*
|
37
|
+
* @return {LogEntry[]}
|
38
|
+
*/
|
39
|
+
getLogs() {
|
40
|
+
return this.entries;
|
41
|
+
}
|
42
|
+
|
43
|
+
toString() {
|
44
|
+
return this.getLogs().map(entry => entry.message).join('\n');
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
LogData.MAX_LINES = MAX_LINES;
|
49
|
+
|
50
|
+
module.exports = LogData;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const FS = require("node:fs");
|
2
|
+
const YAML = require("yaml");
|
3
|
+
|
4
|
+
|
5
|
+
exports.readYML = function readYML(path) {
|
6
|
+
let rawYaml = FS.readFileSync(path);
|
7
|
+
|
8
|
+
try {
|
9
|
+
return YAML.parse(rawYaml.toString());
|
10
|
+
} catch(err) {
|
11
|
+
throw new Error('Failed to parse plan YAML: ' + err);
|
12
|
+
}
|
13
|
+
}
|