verteilen-core 1.2.4 → 1.2.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.
- package/dist/client/analysis.d.ts +35 -0
- package/dist/client/analysis.js +382 -0
- package/dist/client/client.d.ts +25 -0
- package/dist/client/client.js +227 -0
- package/dist/client/cluster.d.ts +1 -0
- package/dist/{src/client → client}/cluster.js +1 -2
- package/dist/client/database.d.ts +13 -0
- package/dist/client/database.js +37 -0
- package/dist/client/execute.d.ts +24 -0
- package/dist/{src/client → client}/execute.js +61 -51
- package/dist/client/http.d.ts +7 -0
- package/dist/client/http.js +40 -0
- package/dist/client/javascript.d.ts +47 -0
- package/dist/{src/client → client}/javascript.js +110 -136
- package/dist/client/job_database.d.ts +10 -0
- package/dist/client/job_database.js +34 -0
- package/dist/client/job_execute.d.ts +20 -0
- package/dist/client/job_execute.js +173 -0
- package/dist/client/os.d.ts +29 -0
- package/dist/client/os.js +197 -0
- package/dist/client/resource.d.ts +7 -0
- package/dist/client/resource.js +107 -0
- package/dist/client/shell.d.ts +16 -0
- package/dist/client/shell.js +122 -0
- package/dist/computed.d.ts +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -3
- package/dist/interface/base.d.ts +70 -0
- package/dist/interface/bus.d.ts +90 -0
- package/dist/interface/enum.d.ts +143 -0
- package/dist/interface/execute.d.ts +20 -0
- package/dist/interface/record.d.ts +93 -0
- package/dist/interface/server.d.ts +76 -0
- package/dist/interface/struct.d.ts +182 -0
- package/dist/interface/table.d.ts +20 -0
- package/dist/interface/ui.d.ts +29 -0
- package/dist/interface.d.ts +29 -0
- package/dist/plugins/i18n.d.ts +1666 -0
- package/dist/script/console_manager.d.ts +18 -0
- package/dist/script/console_manager.js +131 -0
- package/dist/script/console_server_manager.d.ts +13 -0
- package/dist/script/console_server_manager.js +40 -0
- package/dist/script/execute/base.d.ts +45 -0
- package/dist/script/execute/base.js +200 -0
- package/dist/script/execute/feedback.d.ts +12 -0
- package/dist/script/execute/feedback.js +179 -0
- package/dist/script/execute/interface.d.ts +8 -0
- package/dist/script/execute/region_job.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_job.js +1 -0
- package/dist/script/execute/region_project.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_project.js +4 -0
- package/dist/script/execute/region_subtask.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_subtask.js +1 -0
- package/dist/script/execute/region_task.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_task.js +4 -0
- package/dist/script/execute/runner.d.ts +14 -0
- package/dist/script/execute/runner.js +264 -0
- package/dist/script/execute/util_parser.d.ts +14 -0
- package/dist/script/execute/util_parser.js +135 -0
- package/dist/script/execute_manager.d.ts +25 -0
- package/dist/script/execute_manager.js +297 -0
- package/dist/script/socket_manager.d.ts +31 -0
- package/dist/script/socket_manager.js +263 -0
- package/dist/script/webhook_manager.d.ts +3 -0
- package/dist/script/webhook_server_manager.d.ts +13 -0
- package/dist/script/webhook_server_manager.js +133 -0
- package/dist/server/detail.d.ts +72 -0
- package/dist/server/detail.js +451 -0
- package/dist/server/io.d.ts +46 -0
- package/dist/{src/server → server}/io.js +42 -51
- package/dist/server/plugin.d.ts +18 -0
- package/dist/{src/server → server}/plugin.js +45 -54
- package/dist/server/server.d.ts +27 -0
- package/dist/server/server.js +53 -0
- package/dist/server.d.ts +4 -0
- package/dist/util/console_handle.d.ts +20 -0
- package/dist/util/console_handle.js +244 -0
- package/dist/util/log_handle.d.ts +23 -0
- package/dist/util/log_handle.js +224 -0
- package/index.ts +1 -6
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/test/TEST.d.ts +1 -0
- package/test/TEST.js +88 -0
- package/test/client/execute.test.d.ts +1 -0
- package/{dist/test → test}/client/execute.test.js +6 -15
- package/test/client/javascript.test.d.ts +1 -0
- package/{dist/test → test}/client/javascript.test.js +21 -30
- package/test/client/server.test.d.ts +1 -0
- package/test/client/task.test.d.ts +1 -0
- package/{dist/test → test}/client/task.test.js +1 -1
- package/test/script/parser.test.d.ts +1 -0
- package/test/script/socket.test.d.ts +1 -0
- package/tsconfig.json +8 -4
- package/dist/jest.config.js +0 -8
- package/dist/src/client/analysis.js +0 -383
- package/dist/src/client/client.js +0 -233
- package/dist/src/client/database.js +0 -36
- package/dist/src/client/http.js +0 -37
- package/dist/src/client/job_database.js +0 -36
- package/dist/src/client/job_execute.js +0 -171
- package/dist/src/client/job_parameter.js +0 -36
- package/dist/src/client/os.js +0 -202
- package/dist/src/client/parameter.js +0 -36
- package/dist/src/client/resource.js +0 -118
- package/dist/src/client/shell.js +0 -118
- package/dist/src/script/console_manager.js +0 -125
- package/dist/src/script/console_server_manager.js +0 -37
- package/dist/src/script/execute/base.js +0 -197
- package/dist/src/script/execute/feedback.js +0 -188
- package/dist/src/script/execute/runner.js +0 -274
- package/dist/src/script/execute/util_parser.js +0 -137
- package/dist/src/script/execute_manager.js +0 -309
- package/dist/src/script/socket_manager.js +0 -260
- package/dist/src/script/webhook_server_manager.js +0 -140
- package/dist/src/server/detail.js +0 -428
- package/dist/src/server/server.js +0 -51
- package/dist/src/util/console_handle.js +0 -248
- package/dist/src/util/log_handle.js +0 -230
- package/dist/src/util/server/console_handle.js +0 -248
- package/dist/src/util/server/log_handle.js +0 -230
- package/dist/test/TEST.js +0 -105
- /package/dist/{src/computed.js → computed.js} +0 -0
- /package/dist/{src/interface → interface}/base.js +0 -0
- /package/dist/{src/interface → interface}/bus.js +0 -0
- /package/dist/{src/interface → interface}/enum.js +0 -0
- /package/dist/{src/interface → interface}/execute.js +0 -0
- /package/dist/{src/interface → interface}/record.js +0 -0
- /package/dist/{src/interface → interface}/server.js +0 -0
- /package/dist/{src/interface → interface}/struct.js +0 -0
- /package/dist/{src/interface → interface}/table.js +0 -0
- /package/dist/{src/interface → interface}/ui.js +0 -0
- /package/dist/{src/interface.js → interface.js} +0 -0
- /package/dist/{src/lan → lan}/en.json +0 -0
- /package/dist/{src/lan → lan}/zh_TW.json +0 -0
- /package/dist/{src/plugins → plugins}/i18n.js +0 -0
- /package/dist/{src/script → script}/execute/interface.js +0 -0
- /package/dist/{src/script → script}/webhook_manager.js +0 -0
- /package/dist/{src/server.js → server.js} +0 -0
- /package/{dist/test → test}/client/server.test.js +0 -0
- /package/{dist/test → test}/script/parser.test.js +0 -0
- /package/{dist/test → test}/script/socket.test.js +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Util_Parser = void 0;
|
|
5
|
-
const expressionparser_1 = require("expressionparser");
|
|
6
|
-
const interface_1 = require("../../interface");
|
|
7
|
-
class Util_Parser {
|
|
8
|
-
get count() {
|
|
9
|
-
return this.paras.length;
|
|
10
|
-
}
|
|
11
|
-
constructor(_paras) {
|
|
12
|
-
this.paras = [];
|
|
13
|
-
this.clone = () => {
|
|
14
|
-
const b = JSON.parse(JSON.stringify(this.paras));
|
|
15
|
-
return new _a(b);
|
|
16
|
-
};
|
|
17
|
-
this.replacePara = (text) => {
|
|
18
|
-
let buffer = '';
|
|
19
|
-
let store = '';
|
|
20
|
-
let state = false;
|
|
21
|
-
let ignore = -1;
|
|
22
|
-
let useExp = false;
|
|
23
|
-
for (const v of text) {
|
|
24
|
-
if (v == interface_1.IGNORE_CHARACTER && ignore == -1)
|
|
25
|
-
ignore = 0;
|
|
26
|
-
else if (ignore == 0)
|
|
27
|
-
ignore = 1;
|
|
28
|
-
else if (ignore == 1)
|
|
29
|
-
ignore = 2;
|
|
30
|
-
else if (ignore == 2)
|
|
31
|
-
ignore = -1;
|
|
32
|
-
if (v == interface_1.ENV_CHARACTER && ignore == -1) {
|
|
33
|
-
state = !state;
|
|
34
|
-
if (!state) {
|
|
35
|
-
if (useExp) {
|
|
36
|
-
buffer += this.parse(store);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
buffer += this._replacePara(store);
|
|
40
|
-
}
|
|
41
|
-
store = "";
|
|
42
|
-
useExp = false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (v == '{' && state && store.length == 0)
|
|
46
|
-
useExp = true;
|
|
47
|
-
if (state && v != interface_1.ENV_CHARACTER && (ignore != 0))
|
|
48
|
-
store += v;
|
|
49
|
-
if (!state && v != interface_1.ENV_CHARACTER && (ignore != 0))
|
|
50
|
-
buffer += (ignore > 0 ? (interface_1.ENV_CHARACTER + v) : v);
|
|
51
|
-
}
|
|
52
|
-
return buffer;
|
|
53
|
-
};
|
|
54
|
-
this.parse = (str) => {
|
|
55
|
-
str = str.substring(1, str.length - 1);
|
|
56
|
-
const parser = (0, expressionparser_1.init)(expressionparser_1.formula, (term) => {
|
|
57
|
-
if (term.includes("_ck_")) {
|
|
58
|
-
const index = this.paras.findIndex(x => x.key == "ck");
|
|
59
|
-
if (index != -1)
|
|
60
|
-
term = _a.replaceAll(term, "_ck_", this.paras[index].value);
|
|
61
|
-
}
|
|
62
|
-
const index = this.paras.findIndex(x => x.key == term);
|
|
63
|
-
if (index != -1) {
|
|
64
|
-
const n = Number(this.paras[index].value);
|
|
65
|
-
if (Number.isNaN(n))
|
|
66
|
-
return this.paras[index].value;
|
|
67
|
-
return n;
|
|
68
|
-
}
|
|
69
|
-
else
|
|
70
|
-
return 0;
|
|
71
|
-
});
|
|
72
|
-
const r = parser.expressionToValue(str).toString();
|
|
73
|
-
return r;
|
|
74
|
-
};
|
|
75
|
-
this._replacePara = (store) => {
|
|
76
|
-
const index = this.paras.findIndex(x => x.key == store);
|
|
77
|
-
if (index == -1)
|
|
78
|
-
return `%${store}%`;
|
|
79
|
-
return this.paras[index].value;
|
|
80
|
-
};
|
|
81
|
-
this.paras = _paras;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.Util_Parser = Util_Parser;
|
|
85
|
-
_a = Util_Parser;
|
|
86
|
-
Util_Parser.to_keyvalue = (p) => {
|
|
87
|
-
return [
|
|
88
|
-
..._a._to_keyvalue(p.containers)
|
|
89
|
-
];
|
|
90
|
-
};
|
|
91
|
-
Util_Parser.getDeepKeys = (obj, name) => {
|
|
92
|
-
let keys = [];
|
|
93
|
-
for (var key in obj) {
|
|
94
|
-
keys.push([name ? name + "." + key : key, obj[key]]);
|
|
95
|
-
if (typeof obj[key] === "object") {
|
|
96
|
-
if (Array.isArray(obj[key])) {
|
|
97
|
-
if (typeof obj[key]['length'] === 'number') {
|
|
98
|
-
keys.push([name ? name + "." + key + ".length" : key + ".length", obj[key]['length']]);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
var subkeys = _a.getDeepKeys(obj[key]);
|
|
102
|
-
keys = keys.concat(subkeys.map(function (subkey) {
|
|
103
|
-
return [name ? name + "." + key + "." + subkey[0] : key + "." + subkey[0], subkey[1]];
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return keys;
|
|
108
|
-
};
|
|
109
|
-
Util_Parser._to_keyvalue = (p) => {
|
|
110
|
-
const r = [];
|
|
111
|
-
r.push(...p.filter(x => x.type == interface_1.DataType.Boolean || x.type == interface_1.DataType.String || x.type == interface_1.DataType.Textarea || x.type == interface_1.DataType.Number || x.type == interface_1.DataType.Expression).map(x => { return { key: x.name, value: x.value.toString() }; }));
|
|
112
|
-
const objs = p.filter(x => x.type == interface_1.DataType.Object);
|
|
113
|
-
const lists = p.filter(x => x.type == interface_1.DataType.List);
|
|
114
|
-
const selects = p.filter(x => x.type == interface_1.DataType.Select);
|
|
115
|
-
for (const obj of objs) {
|
|
116
|
-
const v = obj.value;
|
|
117
|
-
const keys = _a.getDeepKeys(v, obj.name);
|
|
118
|
-
r.push(...keys.map(x => { return { key: x[0], value: x[1].toString() }; }));
|
|
119
|
-
}
|
|
120
|
-
for (const list of lists) {
|
|
121
|
-
const a = list.value;
|
|
122
|
-
r.push(...a.map((x, index) => { return { key: list.name + "." + String(index), value: x }; }));
|
|
123
|
-
r.push({ key: list.name + ".length", value: a.length });
|
|
124
|
-
}
|
|
125
|
-
for (const select of selects) {
|
|
126
|
-
const a = select.meta;
|
|
127
|
-
const target = a[select.value];
|
|
128
|
-
r.push({ key: select.name, value: target });
|
|
129
|
-
}
|
|
130
|
-
return r;
|
|
131
|
-
};
|
|
132
|
-
Util_Parser.replaceAll = (str, fi, tar) => {
|
|
133
|
-
let p = str;
|
|
134
|
-
while (p.includes(fi))
|
|
135
|
-
p = p.replace(fi, tar);
|
|
136
|
-
return p;
|
|
137
|
-
};
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExecuteManager = void 0;
|
|
4
|
-
const interface_1 = require("../interface");
|
|
5
|
-
const runner_1 = require("./execute/runner");
|
|
6
|
-
class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.Update = () => {
|
|
10
|
-
var _a;
|
|
11
|
-
if (this.state != interface_1.ExecuteState.RUNNING)
|
|
12
|
-
return;
|
|
13
|
-
else if (this.current_p == undefined && this.current_projects.length > 0) {
|
|
14
|
-
this.current_p = this.current_projects[0];
|
|
15
|
-
this.messager_log(`[Execute] Project Start ${this.current_p.uuid}`);
|
|
16
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectStart([this.current_p, 0]);
|
|
17
|
-
this.SyncDatabase(this.current_p);
|
|
18
|
-
}
|
|
19
|
-
else if (this.current_p != undefined) {
|
|
20
|
-
if (this.first)
|
|
21
|
-
this.first = false;
|
|
22
|
-
this.ExecuteProject(this.current_p);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
this.Stop = () => {
|
|
26
|
-
this.current_nodes.forEach(x => {
|
|
27
|
-
const h = {
|
|
28
|
-
name: 'stop_job',
|
|
29
|
-
message: 'Stop All Jobs',
|
|
30
|
-
data: {}
|
|
31
|
-
};
|
|
32
|
-
x.websocket.send(JSON.stringify(h));
|
|
33
|
-
});
|
|
34
|
-
this.jobstack = 0;
|
|
35
|
-
this.current_nodes.forEach(x => x.current_job = []);
|
|
36
|
-
};
|
|
37
|
-
this.Register = (lib) => {
|
|
38
|
-
this.current_projects = this.record.projects;
|
|
39
|
-
this.current_nodes = [];
|
|
40
|
-
this.record.nodes.forEach(x => {
|
|
41
|
-
const n = this.websocket_manager.targets.find(y => y.uuid == x.uuid);
|
|
42
|
-
if (n != undefined)
|
|
43
|
-
this.current_nodes.push(n);
|
|
44
|
-
});
|
|
45
|
-
this.messager_log(`[Execute] Start executing, Project count: ${this.current_projects.length}, Node count: ${this.current_nodes.length}`);
|
|
46
|
-
if (this.state == interface_1.ExecuteState.RUNNING) {
|
|
47
|
-
this.messager_log(`[Execute] Init error, There are projects being execute right now`);
|
|
48
|
-
return -1;
|
|
49
|
-
}
|
|
50
|
-
if (this.current_nodes.length == 0) {
|
|
51
|
-
this.messager_log(`[Execute] Node count should be bigger than one`);
|
|
52
|
-
return -1;
|
|
53
|
-
}
|
|
54
|
-
if (this.current_projects.map(x => x.task.length).reduce((acc, cur) => acc + cur, 0) == 0) {
|
|
55
|
-
this.messager_log(`[Execute] No task can be executing`);
|
|
56
|
-
return -1;
|
|
57
|
-
}
|
|
58
|
-
if (!this.validation(this.current_projects)) {
|
|
59
|
-
this.messager_log(`[Execute] Init failed, Format checking error`);
|
|
60
|
-
return -1;
|
|
61
|
-
}
|
|
62
|
-
if (lib != undefined)
|
|
63
|
-
this.libs = this.filter_lib(this.record.projects, lib);
|
|
64
|
-
else
|
|
65
|
-
this.libs = { libs: [] };
|
|
66
|
-
this.state = interface_1.ExecuteState.RUNNING;
|
|
67
|
-
this.messager_log(`[Execute] Init successfully, Enter process right now, length: ${this.current_projects.length}`);
|
|
68
|
-
let i = 0;
|
|
69
|
-
for (const x of this.current_projects) {
|
|
70
|
-
if (x.task.length > 0) {
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
i++;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return i;
|
|
78
|
-
};
|
|
79
|
-
this.Clean = () => {
|
|
80
|
-
this.current_projects = [];
|
|
81
|
-
this.current_p = undefined;
|
|
82
|
-
this.current_t = undefined;
|
|
83
|
-
this.current_cron = [];
|
|
84
|
-
this.current_job = [];
|
|
85
|
-
this.current_nodes = [];
|
|
86
|
-
this.current_multithread = 1;
|
|
87
|
-
this.state = interface_1.ExecuteState.NONE;
|
|
88
|
-
};
|
|
89
|
-
this.Release = () => {
|
|
90
|
-
this.current_nodes.forEach(x => this.release(x));
|
|
91
|
-
};
|
|
92
|
-
this.NewConnection = (source) => {
|
|
93
|
-
if (this.state == interface_1.ExecuteState.RUNNING && this.localPara != undefined) {
|
|
94
|
-
this.sync_para(this.localPara, source);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
this.Disconnect = (source) => {
|
|
98
|
-
var _a;
|
|
99
|
-
if (this.current_p == undefined)
|
|
100
|
-
return;
|
|
101
|
-
if (this.current_t == undefined)
|
|
102
|
-
return;
|
|
103
|
-
if (this.current_job.length > 0) {
|
|
104
|
-
const singleContainIt = this.current_job.filter(x => x.uuid == source.uuid && x.state == interface_1.ExecuteState.RUNNING);
|
|
105
|
-
singleContainIt.forEach((x, index) => {
|
|
106
|
-
x.uuid = '';
|
|
107
|
-
x.state = interface_1.ExecuteState.NONE;
|
|
108
|
-
});
|
|
109
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
|
|
110
|
-
}
|
|
111
|
-
else if (this.current_cron.length > 0) {
|
|
112
|
-
const cronContainIt = this.current_cron.filter(x => x.work.filter(y => y.state == interface_1.ExecuteState.RUNNING && y.uuid == source.uuid).length > 0);
|
|
113
|
-
cronContainIt.forEach(element => {
|
|
114
|
-
var _a;
|
|
115
|
-
element.work.forEach(x => {
|
|
116
|
-
x.uuid = '';
|
|
117
|
-
x.state = interface_1.ExecuteState.NONE;
|
|
118
|
-
});
|
|
119
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskUpdate([this.current_t, element.id - 1, '', interface_1.ExecuteState.NONE]);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
source.current_job = [];
|
|
123
|
-
};
|
|
124
|
-
this.ClearState = (task_index) => {
|
|
125
|
-
var _a, _b;
|
|
126
|
-
if (this.current_p == undefined)
|
|
127
|
-
return;
|
|
128
|
-
if (this.current_t == undefined)
|
|
129
|
-
return;
|
|
130
|
-
if (this.current_job.length > 0) {
|
|
131
|
-
this.current_job = [];
|
|
132
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
|
|
133
|
-
}
|
|
134
|
-
else if (this.current_cron.length > 0) {
|
|
135
|
-
const target = this.current_cron[task_index];
|
|
136
|
-
target.work.forEach(x => {
|
|
137
|
-
x.uuid = '';
|
|
138
|
-
x.state = interface_1.ExecuteState.NONE;
|
|
139
|
-
});
|
|
140
|
-
(_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeSubtaskUpdate([this.current_t, target.id - 1, '', interface_1.ExecuteState.NONE]);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
this.SkipProject = () => {
|
|
144
|
-
return this.jumpProject(true);
|
|
145
|
-
};
|
|
146
|
-
this.PreviousProject = () => {
|
|
147
|
-
return this.jumpProject(false);
|
|
148
|
-
};
|
|
149
|
-
this.SkipTask = () => {
|
|
150
|
-
return this.jumpTask(true);
|
|
151
|
-
};
|
|
152
|
-
this.PreviousTask = () => {
|
|
153
|
-
return this.jumpTask(false);
|
|
154
|
-
};
|
|
155
|
-
this.SkipSubTask = (v) => {
|
|
156
|
-
if (this.current_p == undefined) {
|
|
157
|
-
console.error("No project exist, Skip failed");
|
|
158
|
-
return -2;
|
|
159
|
-
}
|
|
160
|
-
if (this.current_t == undefined) {
|
|
161
|
-
console.error("Project has no task, Skip failed");
|
|
162
|
-
return -2;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
if (!this.current_t.cronjob) {
|
|
166
|
-
return this.SkipTask();
|
|
167
|
-
}
|
|
168
|
-
const min = Math.min(v, this.current_cron.length);
|
|
169
|
-
for (let i = 0; i < min; i++) {
|
|
170
|
-
const ps = this.current_cron[i].work.filter(y => y.state != interface_1.ExecuteState.FINISH && y.state != interface_1.ExecuteState.ERROR);
|
|
171
|
-
ps.forEach(x => x.state = interface_1.ExecuteState.FINISH);
|
|
172
|
-
}
|
|
173
|
-
return min;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
this.jumpProject = (forward) => {
|
|
177
|
-
if (this.current_projects.length == 0) {
|
|
178
|
-
console.error("There is no project exists");
|
|
179
|
-
return -2;
|
|
180
|
-
}
|
|
181
|
-
if (this.current_p == undefined) {
|
|
182
|
-
return forward ? this.skipProjectFirst() : -2;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
return this._jumpProject(forward);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
this.jumpTask = (forward) => {
|
|
189
|
-
if (this.current_p == undefined)
|
|
190
|
-
return -2;
|
|
191
|
-
if (this.current_t == undefined) {
|
|
192
|
-
return forward ? this.skipTaskFirst() : this.previousTaskFirst();
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
return forward ? this.skipTask() : this.previousTask();
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
this.skipProjectFirst = () => {
|
|
199
|
-
var _a;
|
|
200
|
-
this.current_p = this.current_projects[1];
|
|
201
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectStart([this.current_p, 1]);
|
|
202
|
-
this.SyncDatabase(this.current_p);
|
|
203
|
-
this.state = interface_1.ExecuteState.RUNNING;
|
|
204
|
-
return 1;
|
|
205
|
-
};
|
|
206
|
-
this._jumpProject = (forward) => {
|
|
207
|
-
var _a, _b;
|
|
208
|
-
const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
|
|
209
|
-
if (forward)
|
|
210
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeProjectFinish([this.current_p, index]);
|
|
211
|
-
const atend = forward ? index == this.current_projects.length - 1 : index == 0;
|
|
212
|
-
if (atend) {
|
|
213
|
-
if (forward) {
|
|
214
|
-
this.current_p = undefined;
|
|
215
|
-
this.current_t = undefined;
|
|
216
|
-
this.state = interface_1.ExecuteState.FINISH;
|
|
217
|
-
this.messager_log(`[Execute] Skip project to Finish !`);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
this.current_p = this.current_projects[0];
|
|
221
|
-
this.current_t = undefined;
|
|
222
|
-
this.state = interface_1.ExecuteState.RUNNING;
|
|
223
|
-
this.messager_log(`[Execute] Previous project to Begining !`);
|
|
224
|
-
}
|
|
225
|
-
return -1;
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
const next = forward ? this.current_projects[index + 1] : this.current_projects[index - 1];
|
|
229
|
-
this.current_p = next;
|
|
230
|
-
this.current_t = undefined;
|
|
231
|
-
this.state = interface_1.ExecuteState.RUNNING;
|
|
232
|
-
if (forward) {
|
|
233
|
-
this.messager_log(`[Execute] Skip project ${index}. ${this.current_p.uuid}`);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
this.messager_log(`[Execute] Previous project ${index}. ${this.current_p.uuid}`);
|
|
237
|
-
}
|
|
238
|
-
(_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeProjectStart([this.current_p, index + (forward ? 1 : -1)]);
|
|
239
|
-
this.SyncDatabase(this.current_p);
|
|
240
|
-
return index;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
this.skipTaskFirst = () => {
|
|
244
|
-
var _a;
|
|
245
|
-
if (this.current_p.task.length > 0) {
|
|
246
|
-
this.current_t = this.current_p.task[0];
|
|
247
|
-
const taskCount = this.get_task_state_count(this.current_t);
|
|
248
|
-
if (this.current_t.cronjob) {
|
|
249
|
-
this.Init_CronContainer(this.current_t, taskCount);
|
|
250
|
-
}
|
|
251
|
-
this.t_state = interface_1.ExecuteState.NONE;
|
|
252
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([this.current_t, taskCount]);
|
|
253
|
-
return 0;
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
console.error("Project has no task, Skip failed");
|
|
257
|
-
return -2;
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
this.previousTaskFirst = () => {
|
|
261
|
-
const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
|
|
262
|
-
if (index == 0) {
|
|
263
|
-
this.current_t = undefined;
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
this.current_p = this.current_projects[index - 1];
|
|
267
|
-
this.messager_log(`[Execute] Previous task ${index}. Jump Project: ${this.current_p.uuid}`);
|
|
268
|
-
}
|
|
269
|
-
this.current_job = [];
|
|
270
|
-
this.t_state = interface_1.ExecuteState.NONE;
|
|
271
|
-
return index;
|
|
272
|
-
};
|
|
273
|
-
this.skipTask = () => {
|
|
274
|
-
var _a, _b, _c;
|
|
275
|
-
const index = this.current_p.task.findIndex(x => x.uuid == this.current_t.uuid);
|
|
276
|
-
if (index == this.current_p.task.length - 1) {
|
|
277
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskFinish(this.current_t);
|
|
278
|
-
this.current_t = undefined;
|
|
279
|
-
this.messager_log(`[Execute] Skip task to Finish !`);
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
(_b = this.proxy) === null || _b === void 0 ? void 0 : _b.executeTaskFinish(this.current_t);
|
|
283
|
-
this.current_t = this.current_p.task[index + 1];
|
|
284
|
-
this.messager_log(`[Execute] Skip task ${index}. ${this.current_t.uuid}`);
|
|
285
|
-
const taskCount = this.get_task_state_count(this.current_t);
|
|
286
|
-
if (this.current_t.cronjob) {
|
|
287
|
-
this.Init_CronContainer(this.current_t, taskCount);
|
|
288
|
-
}
|
|
289
|
-
(_c = this.proxy) === null || _c === void 0 ? void 0 : _c.executeTaskStart([this.current_t, taskCount]);
|
|
290
|
-
}
|
|
291
|
-
this.current_job = [];
|
|
292
|
-
this.t_state = interface_1.ExecuteState.NONE;
|
|
293
|
-
return index;
|
|
294
|
-
};
|
|
295
|
-
this.previousTask = () => {
|
|
296
|
-
var _a;
|
|
297
|
-
const index = this.current_p.task.findIndex(x => x.uuid == this.current_t.uuid);
|
|
298
|
-
this.current_t = this.current_p.task[index - 1];
|
|
299
|
-
const taskCount = this.get_task_state_count(this.current_t);
|
|
300
|
-
if (this.current_t.cronjob) {
|
|
301
|
-
this.Init_CronContainer(this.current_t, taskCount);
|
|
302
|
-
}
|
|
303
|
-
this.t_state = interface_1.ExecuteState.NONE;
|
|
304
|
-
(_a = this.proxy) === null || _a === void 0 ? void 0 : _a.executeTaskStart([this.current_t, taskCount]);
|
|
305
|
-
return 0;
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
exports.ExecuteManager = ExecuteManager;
|