verteilen-core 1.3.21 → 1.3.23
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.js +6 -8
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.js +1 -1
- package/dist/client/job_execute.d.ts +2 -2
- package/dist/interface/base.d.ts +9 -6
- package/dist/interface/base.js +10 -1
- package/dist/interface/bus.d.ts +2 -5
- package/dist/interface/execute.d.ts +1 -1
- package/dist/interface/log.d.ts +51 -0
- package/dist/interface/log.js +2 -0
- package/dist/interface/plugin.d.ts +79 -0
- package/dist/interface/plugin.js +2 -0
- package/dist/interface/record.d.ts +0 -49
- package/dist/interface/struct.d.ts +2 -80
- package/dist/interface/table.d.ts +2 -1
- package/dist/interface.d.ts +4 -2
- package/dist/interface.js +4 -2
- package/dist/lan/en.json +7 -2
- package/dist/lan/zh_TW.json +7 -2
- package/dist/plugins/i18n.d.ts +20 -0
- package/dist/server/detail/console_handle.d.ts +20 -0
- package/dist/server/detail/console_handle.js +244 -0
- package/dist/server/detail/log_handle.d.ts +23 -0
- package/dist/server/detail/log_handle.js +224 -0
- package/dist/server/detail.d.ts +6 -4
- package/dist/server/detail.js +54 -52
- package/dist/server/plugin.d.ts +3 -5
- package/dist/server/plugin.js +68 -158
- package/dist/server/server.js +0 -1
- package/package.json +1 -1
- package/src/client/analysis.ts +10 -12
- package/src/client/client.ts +3 -3
- package/src/client/cluster.ts +2 -2
- package/src/client/job_execute.ts +3 -3
- package/src/interface/base.ts +19 -7
- package/src/interface/bus.ts +2 -5
- package/src/interface/execute.ts +1 -1
- package/src/interface/log.ts +63 -0
- package/src/interface/plugin.ts +247 -0
- package/src/interface/record.ts +0 -62
- package/src/interface/struct.ts +2 -112
- package/src/interface/table.ts +2 -1
- package/src/interface.ts +4 -2
- package/src/lan/en.json +7 -2
- package/src/lan/zh_TW.json +7 -2
- package/src/{util → server/detail}/console_handle.ts +3 -3
- package/src/{util → server/detail}/log_handle.ts +2 -2
- package/src/server/detail.ts +74 -60
- package/src/server/io.ts +3 -0
- package/src/server/plugin.ts +118 -166
- package/src/server/server.ts +0 -1
package/dist/plugins/i18n.d.ts
CHANGED
|
@@ -147,6 +147,9 @@ export declare const i18nDefaultData: {
|
|
|
147
147
|
"delete-job-confirm": string;
|
|
148
148
|
"delete-task": string;
|
|
149
149
|
"delete-task-confirm": string;
|
|
150
|
+
"create-service": string;
|
|
151
|
+
"delete-service": string;
|
|
152
|
+
"delete-service-confirm": string;
|
|
150
153
|
};
|
|
151
154
|
toolbar: {
|
|
152
155
|
server: string;
|
|
@@ -283,6 +286,7 @@ export declare const i18nDefaultData: {
|
|
|
283
286
|
"job-count": string;
|
|
284
287
|
hidden: string;
|
|
285
288
|
runtime: string;
|
|
289
|
+
value: string;
|
|
286
290
|
};
|
|
287
291
|
codehint: {
|
|
288
292
|
v_path: string;
|
|
@@ -359,6 +363,7 @@ export declare const i18nDefaultData: {
|
|
|
359
363
|
selectall: string;
|
|
360
364
|
unselectall: string;
|
|
361
365
|
project: string;
|
|
366
|
+
service: string;
|
|
362
367
|
task: string;
|
|
363
368
|
job: string;
|
|
364
369
|
database: string;
|
|
@@ -571,6 +576,9 @@ export declare const i18nDefaultData: {
|
|
|
571
576
|
"delete-job-confirm": string;
|
|
572
577
|
"delete-task": string;
|
|
573
578
|
"delete-task-confirm": string;
|
|
579
|
+
"create-service": string;
|
|
580
|
+
"delete-service": string;
|
|
581
|
+
"delete-service-confirm": string;
|
|
574
582
|
};
|
|
575
583
|
toolbar: {
|
|
576
584
|
server: string;
|
|
@@ -707,6 +715,7 @@ export declare const i18nDefaultData: {
|
|
|
707
715
|
"job-count": string;
|
|
708
716
|
hidden: string;
|
|
709
717
|
runtime: string;
|
|
718
|
+
value: string;
|
|
710
719
|
};
|
|
711
720
|
codehint: {
|
|
712
721
|
v_path: string;
|
|
@@ -783,6 +792,7 @@ export declare const i18nDefaultData: {
|
|
|
783
792
|
selectall: string;
|
|
784
793
|
unselectall: string;
|
|
785
794
|
project: string;
|
|
795
|
+
service: string;
|
|
786
796
|
task: string;
|
|
787
797
|
job: string;
|
|
788
798
|
database: string;
|
|
@@ -998,6 +1008,9 @@ export declare const i18n: import("vue-i18n").I18n<{
|
|
|
998
1008
|
"delete-job-confirm": string;
|
|
999
1009
|
"delete-task": string;
|
|
1000
1010
|
"delete-task-confirm": string;
|
|
1011
|
+
"create-service": string;
|
|
1012
|
+
"delete-service": string;
|
|
1013
|
+
"delete-service-confirm": string;
|
|
1001
1014
|
};
|
|
1002
1015
|
toolbar: {
|
|
1003
1016
|
server: string;
|
|
@@ -1134,6 +1147,7 @@ export declare const i18n: import("vue-i18n").I18n<{
|
|
|
1134
1147
|
"job-count": string;
|
|
1135
1148
|
hidden: string;
|
|
1136
1149
|
runtime: string;
|
|
1150
|
+
value: string;
|
|
1137
1151
|
};
|
|
1138
1152
|
codehint: {
|
|
1139
1153
|
v_path: string;
|
|
@@ -1210,6 +1224,7 @@ export declare const i18n: import("vue-i18n").I18n<{
|
|
|
1210
1224
|
selectall: string;
|
|
1211
1225
|
unselectall: string;
|
|
1212
1226
|
project: string;
|
|
1227
|
+
service: string;
|
|
1213
1228
|
task: string;
|
|
1214
1229
|
job: string;
|
|
1215
1230
|
database: string;
|
|
@@ -1422,6 +1437,9 @@ export declare const i18n: import("vue-i18n").I18n<{
|
|
|
1422
1437
|
"delete-job-confirm": string;
|
|
1423
1438
|
"delete-task": string;
|
|
1424
1439
|
"delete-task-confirm": string;
|
|
1440
|
+
"create-service": string;
|
|
1441
|
+
"delete-service": string;
|
|
1442
|
+
"delete-service-confirm": string;
|
|
1425
1443
|
};
|
|
1426
1444
|
toolbar: {
|
|
1427
1445
|
server: string;
|
|
@@ -1558,6 +1576,7 @@ export declare const i18n: import("vue-i18n").I18n<{
|
|
|
1558
1576
|
"job-count": string;
|
|
1559
1577
|
hidden: string;
|
|
1560
1578
|
runtime: string;
|
|
1579
|
+
value: string;
|
|
1561
1580
|
};
|
|
1562
1581
|
codehint: {
|
|
1563
1582
|
v_path: string;
|
|
@@ -1634,6 +1653,7 @@ export declare const i18n: import("vue-i18n").I18n<{
|
|
|
1634
1653
|
selectall: string;
|
|
1635
1654
|
unselectall: string;
|
|
1636
1655
|
project: string;
|
|
1656
|
+
service: string;
|
|
1637
1657
|
task: string;
|
|
1638
1658
|
job: string;
|
|
1639
1659
|
database: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExecutePair, ExecuteProxy, ExecuteState, FeedBack, Job, Database, Project, Record, Task } from "../../interface";
|
|
2
|
+
export declare class Console_Handler {
|
|
3
|
+
receivedPack: (model: ExecutePair, record: Record) => boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class Console_Proxy {
|
|
6
|
+
model: ExecutePair;
|
|
7
|
+
constructor(_model: ExecutePair);
|
|
8
|
+
get execute_proxy(): ExecuteProxy;
|
|
9
|
+
execute_project_start: (d: [Project, number]) => void;
|
|
10
|
+
execute_project_finish: (d: [Project, number]) => void;
|
|
11
|
+
execute_task_start: (d: [Task, number]) => void;
|
|
12
|
+
execute_task_finish: (d: Task) => void;
|
|
13
|
+
execute_subtask_start: (d: [Task, number, string]) => void;
|
|
14
|
+
execute_subtask_update: (d: [Task, number, string, ExecuteState]) => void;
|
|
15
|
+
execute_subtask_end: (d: [Task, number, string]) => void;
|
|
16
|
+
execute_job_start: (d: [Job, number, string]) => void;
|
|
17
|
+
execute_job_finish: (d: [Job, number, string, number]) => void;
|
|
18
|
+
feedback_message: (d: FeedBack) => void;
|
|
19
|
+
update_runtime_database: (d: Database) => void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Console_Proxy = exports.Console_Handler = void 0;
|
|
4
|
+
const interface_1 = require("../../interface");
|
|
5
|
+
class Console_Handler {
|
|
6
|
+
receivedPack = (model, record) => {
|
|
7
|
+
const pass = model.manager.Register();
|
|
8
|
+
if (pass == -1) {
|
|
9
|
+
model.record.running = false;
|
|
10
|
+
model.record.stop = true;
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
model.record.projects = record.projects;
|
|
14
|
+
model.record.nodes = record.nodes;
|
|
15
|
+
model.record.project_state = model.record.projects.map(x => {
|
|
16
|
+
return {
|
|
17
|
+
uuid: x.uuid,
|
|
18
|
+
state: interface_1.ExecuteState.NONE
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
model.record.project_index = pass;
|
|
22
|
+
model.record.project = record.projects[pass].uuid;
|
|
23
|
+
model.record.task_index = 0;
|
|
24
|
+
model.record.task_state = model.record.projects[0].tasks.map(x => {
|
|
25
|
+
return {
|
|
26
|
+
uuid: x.uuid,
|
|
27
|
+
state: interface_1.ExecuteState.NONE
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
model.record.task_state[0].state = interface_1.ExecuteState.RUNNING;
|
|
31
|
+
model.record.task_detail = [];
|
|
32
|
+
const task = model.record.projects[model.record.project_index]?.tasks[model.record.task_index];
|
|
33
|
+
const count = task.cronjob ? (task?.jobs.length ?? 0) : 1;
|
|
34
|
+
for (let i = 0; i < count; i++) {
|
|
35
|
+
model.record.task_detail.push({
|
|
36
|
+
index: i,
|
|
37
|
+
node: "",
|
|
38
|
+
message: [],
|
|
39
|
+
state: interface_1.ExecuteState.NONE
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
model.manager.Update();
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.Console_Handler = Console_Handler;
|
|
47
|
+
class Console_Proxy {
|
|
48
|
+
model;
|
|
49
|
+
constructor(_model) {
|
|
50
|
+
this.model = _model;
|
|
51
|
+
}
|
|
52
|
+
get execute_proxy() {
|
|
53
|
+
const d = {
|
|
54
|
+
executeProjectStart: (data) => { this.execute_project_start(data); },
|
|
55
|
+
executeProjectFinish: (data) => { this.execute_project_finish(data); },
|
|
56
|
+
executeTaskStart: (data) => { this.execute_task_start(data); },
|
|
57
|
+
executeTaskFinish: (data) => { this.execute_task_finish(data); },
|
|
58
|
+
executeSubtaskStart: (data) => { this.execute_subtask_start(data); },
|
|
59
|
+
executeSubtaskUpdate: (data) => { this.execute_subtask_update(data); },
|
|
60
|
+
executeSubtaskFinish: (data) => { this.execute_subtask_end(data); },
|
|
61
|
+
executeJobStart: (data) => { this.execute_job_start(data); },
|
|
62
|
+
executeJobFinish: (data) => { this.execute_job_finish(data); },
|
|
63
|
+
feedbackMessage: (data) => { this.feedback_message(data); },
|
|
64
|
+
updateDatabase: (data) => { this.update_runtime_database(data); }
|
|
65
|
+
};
|
|
66
|
+
return d;
|
|
67
|
+
}
|
|
68
|
+
execute_project_start = (d) => {
|
|
69
|
+
const index = d[1];
|
|
70
|
+
if (index == -1)
|
|
71
|
+
return;
|
|
72
|
+
this.model.record.project = d[0].uuid;
|
|
73
|
+
this.model.record.project_index = index;
|
|
74
|
+
this.model.record.project_state[index].state = interface_1.ExecuteState.RUNNING;
|
|
75
|
+
this.model.record.task_state = this.model.record.projects[index].tasks.map(x => {
|
|
76
|
+
return {
|
|
77
|
+
uuid: x.uuid,
|
|
78
|
+
state: interface_1.ExecuteState.NONE
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
this.model.record.task_detail = [];
|
|
82
|
+
const task = this.model.record.projects[this.model.record.project_index]?.tasks[this.model.record.task_index];
|
|
83
|
+
const count = task.cronjob ? (task?.jobs.length ?? 0) : 1;
|
|
84
|
+
for (let i = 0; i < count; i++) {
|
|
85
|
+
this.model.record.task_detail.push({
|
|
86
|
+
index: i,
|
|
87
|
+
node: "",
|
|
88
|
+
message: [],
|
|
89
|
+
state: interface_1.ExecuteState.NONE
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
console.log("project start: ", this.model.record.projects.length, index);
|
|
93
|
+
};
|
|
94
|
+
execute_project_finish = (d) => {
|
|
95
|
+
if (this.model.record.process_type >= 1) {
|
|
96
|
+
this.model.record.running = false;
|
|
97
|
+
this.model.record.stop = true;
|
|
98
|
+
}
|
|
99
|
+
const index = d[1];
|
|
100
|
+
const size = this.model.record.projects.length;
|
|
101
|
+
if (index == -1)
|
|
102
|
+
return;
|
|
103
|
+
this.model.record.project = "";
|
|
104
|
+
this.model.record.project_state[index].state = interface_1.ExecuteState.FINISH;
|
|
105
|
+
this.model.record.para = undefined;
|
|
106
|
+
console.log("project finish: ", this.model.record.projects.length, index);
|
|
107
|
+
if (index == size - 1) {
|
|
108
|
+
this.model.record.command.push(['clean']);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
execute_task_start = (d) => {
|
|
112
|
+
if (this.model.record.project_index == -1)
|
|
113
|
+
return;
|
|
114
|
+
const index = this.model.record.projects[this.model.record.project_index].tasks.findIndex(x => x.uuid == d[0].uuid);
|
|
115
|
+
if (index == -1)
|
|
116
|
+
return;
|
|
117
|
+
this.model.record.useCron = d[0].cronjob;
|
|
118
|
+
this.model.record.task = d[0].uuid;
|
|
119
|
+
this.model.record.task_index = index;
|
|
120
|
+
this.model.record.task_state[index].state = interface_1.ExecuteState.RUNNING;
|
|
121
|
+
for (let i = 0; i < index; i++)
|
|
122
|
+
this.model.record.task_state[i].state = interface_1.ExecuteState.FINISH;
|
|
123
|
+
for (let i = index + 1; i < this.model.record.task_state.length; i++)
|
|
124
|
+
this.model.record.task_state[i].state = interface_1.ExecuteState.NONE;
|
|
125
|
+
this.model.record.task_detail = [];
|
|
126
|
+
const p = this.model.record.projects[this.model.record.project_index];
|
|
127
|
+
const t = p.tasks[this.model.record.task_index];
|
|
128
|
+
const count = this.model.manager.get_task_state_count(t);
|
|
129
|
+
for (let i = 0; i < count; i++) {
|
|
130
|
+
this.model.record.task_detail.push({
|
|
131
|
+
index: i,
|
|
132
|
+
node: "",
|
|
133
|
+
message: [],
|
|
134
|
+
state: interface_1.ExecuteState.NONE
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
execute_task_finish = (d) => {
|
|
139
|
+
if (this.model.record.process_type == 2) {
|
|
140
|
+
this.model.record.running = false;
|
|
141
|
+
this.model.record.stop = true;
|
|
142
|
+
}
|
|
143
|
+
if (this.model.record.project_index == -1)
|
|
144
|
+
return;
|
|
145
|
+
const index = this.model.record.projects[this.model.record.project_index].tasks.findIndex(x => x.uuid == d.uuid);
|
|
146
|
+
if (index == -1)
|
|
147
|
+
return;
|
|
148
|
+
this.model.record.useCron = false;
|
|
149
|
+
this.model.record.task = "";
|
|
150
|
+
this.model.record.task_state[index].state = interface_1.ExecuteState.FINISH;
|
|
151
|
+
if (index + 1 < this.model.record.task_state.length - 1) {
|
|
152
|
+
this.model.record.task_state[index + 1].state = interface_1.ExecuteState.RUNNING;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
execute_subtask_start = (d) => {
|
|
156
|
+
try {
|
|
157
|
+
this.model.record.task_detail[d[1]].node = d[2] ?? '';
|
|
158
|
+
this.model.record.task_detail[d[1]].state = interface_1.ExecuteState.RUNNING;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error(`execute_subtask_start`, error.message);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
execute_subtask_update = (d) => {
|
|
165
|
+
if (this.model.record.task_detail.length > d[1]) {
|
|
166
|
+
this.model.record.task_detail[d[1]].node = d[2];
|
|
167
|
+
this.model.record.task_detail[d[1]].state = d[3];
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
console.error(`subtask_start ${d[1]} is out of range: ${this.model.record.task_detail.length}`);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
execute_subtask_end = (d) => {
|
|
174
|
+
try {
|
|
175
|
+
this.model.record.task_detail[d[1]].state = interface_1.ExecuteState.FINISH;
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error(`execute_subtask_end`, error.message);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
execute_job_start = (d) => {
|
|
182
|
+
if (this.model.record.project_index == -1)
|
|
183
|
+
return;
|
|
184
|
+
if (!this.model.record.useCron) {
|
|
185
|
+
this.model.record.task_detail[0].node = d[2];
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
execute_job_finish = (d) => {
|
|
189
|
+
if (d[3] == 1) {
|
|
190
|
+
const task = this.model.record.projects[this.model.record.project_index].tasks[this.model.record.task_index];
|
|
191
|
+
const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
|
|
192
|
+
if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
|
|
193
|
+
const cr = task.jobs[index].number_args[0];
|
|
194
|
+
if (cr == interface_1.ConditionResult.None)
|
|
195
|
+
return;
|
|
196
|
+
this.model.record.command.push(['stop']);
|
|
197
|
+
let timer;
|
|
198
|
+
timer = setInterval(() => {
|
|
199
|
+
if (this.model.record.running == false) {
|
|
200
|
+
clearInterval(timer);
|
|
201
|
+
const state = (cr == interface_1.ConditionResult.ThrowTask || cr == interface_1.ConditionResult.ThrowProject) ? interface_1.ExecuteState.ERROR : interface_1.ExecuteState.SKIP;
|
|
202
|
+
const target = this.model.record.task_detail[d[1]];
|
|
203
|
+
if (target != undefined) {
|
|
204
|
+
target.state = state;
|
|
205
|
+
}
|
|
206
|
+
if (cr == interface_1.ConditionResult.Pause)
|
|
207
|
+
return;
|
|
208
|
+
if (cr == interface_1.ConditionResult.SkipProject || cr == interface_1.ConditionResult.ThrowProject) {
|
|
209
|
+
this.model.record.command.push(['skip', 0, state]);
|
|
210
|
+
if (this.model.record.project.length > 0) {
|
|
211
|
+
if (this.model.record.process_type == 0) {
|
|
212
|
+
this.model.record.command.push(['execute', this.model.record.process_type]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else if (cr == interface_1.ConditionResult.SkipTask || cr == interface_1.ConditionResult.ThrowTask) {
|
|
217
|
+
this.model.record.command.push(['skip', 1, state]);
|
|
218
|
+
if (this.model.record.project.length > 0) {
|
|
219
|
+
if (this.model.record.process_type == 0) {
|
|
220
|
+
this.model.record.command.push(['execute', this.model.record.process_type]);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}, 1000);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
feedback_message = (d) => {
|
|
230
|
+
if (d.index == undefined || d.index == -1)
|
|
231
|
+
return;
|
|
232
|
+
const container = this.model.record.task_detail[d.index];
|
|
233
|
+
if (container != undefined) {
|
|
234
|
+
container.message.push(d.message);
|
|
235
|
+
if (container.message.length > interface_1.MESSAGE_LIMIT) {
|
|
236
|
+
container.message.shift();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
update_runtime_database = (d) => {
|
|
241
|
+
this.model.record.para = d;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
exports.Console_Proxy = Console_Proxy;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ExecutePair, ExecuteProxy, ExecuteState, FeedBack, Job, Log, Database, Preference, Project, Task } from "../../interface";
|
|
2
|
+
export declare class Log_Proxy {
|
|
3
|
+
model: ExecutePair;
|
|
4
|
+
logs: Log;
|
|
5
|
+
preference: Preference;
|
|
6
|
+
private task_index;
|
|
7
|
+
private uuid;
|
|
8
|
+
private get target_log();
|
|
9
|
+
constructor(_model: ExecutePair, _log: Log, _preference: Preference);
|
|
10
|
+
get execute_proxy(): ExecuteProxy;
|
|
11
|
+
execute_project_start: (d: [Project, number]) => Promise<void>;
|
|
12
|
+
execute_project_finish: (d: [Project, number]) => void;
|
|
13
|
+
execute_task_start: (d: [Task, number]) => void;
|
|
14
|
+
execute_task_finish: (d: Task) => void;
|
|
15
|
+
execute_subtask_start: (d: [Task, number, string]) => void;
|
|
16
|
+
execute_subtask_update: (d: [Task, number, string, ExecuteState]) => void;
|
|
17
|
+
execute_subtask_end: (d: [Task, number, string]) => void;
|
|
18
|
+
execute_job_start: (d: [Job, number, string]) => void;
|
|
19
|
+
execute_job_finish: (d: [Job, number, string, number]) => void;
|
|
20
|
+
feedback_message: (d: FeedBack) => void;
|
|
21
|
+
update_runtime_database: (d: Database) => void;
|
|
22
|
+
getnewname: (name: string) => Promise<string>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Log_Proxy = void 0;
|
|
37
|
+
const uuid_1 = require("uuid");
|
|
38
|
+
const interface_1 = require("../../interface");
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
class Log_Proxy {
|
|
41
|
+
model;
|
|
42
|
+
logs;
|
|
43
|
+
preference;
|
|
44
|
+
task_index = 0;
|
|
45
|
+
uuid = '';
|
|
46
|
+
get target_log() {
|
|
47
|
+
return this.logs.logs.find(x => x.uuid == this.uuid);
|
|
48
|
+
}
|
|
49
|
+
constructor(_model, _log, _preference) {
|
|
50
|
+
this.model = _model;
|
|
51
|
+
this.logs = _log;
|
|
52
|
+
this.preference = _preference;
|
|
53
|
+
}
|
|
54
|
+
get execute_proxy() {
|
|
55
|
+
const d = {
|
|
56
|
+
executeProjectStart: (data) => { this.execute_project_start(data); },
|
|
57
|
+
executeProjectFinish: (data) => { this.execute_project_finish(data); },
|
|
58
|
+
executeTaskStart: (data) => { this.execute_task_start(data); },
|
|
59
|
+
executeTaskFinish: (data) => { this.execute_task_finish(data); },
|
|
60
|
+
executeSubtaskStart: (data) => { this.execute_subtask_start(data); },
|
|
61
|
+
executeSubtaskUpdate: (data) => { this.execute_subtask_update(data); },
|
|
62
|
+
executeSubtaskFinish: (data) => { this.execute_subtask_end(data); },
|
|
63
|
+
executeJobStart: (data) => { this.execute_job_start(data); },
|
|
64
|
+
executeJobFinish: (data) => { this.execute_job_finish(data); },
|
|
65
|
+
feedbackMessage: (data) => { this.feedback_message(data); },
|
|
66
|
+
updateDatabase: (data) => { this.update_runtime_database(data); }
|
|
67
|
+
};
|
|
68
|
+
return d;
|
|
69
|
+
}
|
|
70
|
+
execute_project_start = async (d) => {
|
|
71
|
+
const target = this.model.record.projects[this.model.record.project_index];
|
|
72
|
+
const title = await this.getnewname(target.title);
|
|
73
|
+
this.uuid = (0, uuid_1.v6)();
|
|
74
|
+
const newlog = {
|
|
75
|
+
uuid: this.uuid,
|
|
76
|
+
filename: title,
|
|
77
|
+
dirty: true,
|
|
78
|
+
output: this.preference.log,
|
|
79
|
+
project: target,
|
|
80
|
+
state: interface_1.ExecuteState.RUNNING,
|
|
81
|
+
start_timer: Date.now(),
|
|
82
|
+
database: d[0].database,
|
|
83
|
+
end_timer: 0,
|
|
84
|
+
logs: target.tasks.map(x => {
|
|
85
|
+
return {
|
|
86
|
+
start_timer: 0,
|
|
87
|
+
end_timer: 0,
|
|
88
|
+
task_state: {
|
|
89
|
+
uuid: x.uuid,
|
|
90
|
+
state: interface_1.ExecuteState.NONE
|
|
91
|
+
},
|
|
92
|
+
task_detail: []
|
|
93
|
+
};
|
|
94
|
+
})
|
|
95
|
+
};
|
|
96
|
+
this.logs.logs = [newlog].concat(this.logs.logs);
|
|
97
|
+
};
|
|
98
|
+
execute_project_finish = (d) => {
|
|
99
|
+
if (this.target_log == undefined)
|
|
100
|
+
return;
|
|
101
|
+
this.target_log.state = interface_1.ExecuteState.FINISH;
|
|
102
|
+
this.target_log.end_timer = Date.now();
|
|
103
|
+
this.target_log.dirty = true;
|
|
104
|
+
};
|
|
105
|
+
execute_task_start = (d) => {
|
|
106
|
+
if (this.target_log == undefined)
|
|
107
|
+
return;
|
|
108
|
+
const index = this.target_log.project.tasks.findIndex(x => x.uuid == d[0].uuid);
|
|
109
|
+
if (index == -1)
|
|
110
|
+
return;
|
|
111
|
+
this.task_index = index;
|
|
112
|
+
this.target_log.logs[this.task_index].task_detail = [];
|
|
113
|
+
const p = this.model.record.projects[this.model.record.project_index];
|
|
114
|
+
const t = p.tasks[this.task_index];
|
|
115
|
+
const count = this.model.manager.get_task_state_count(t);
|
|
116
|
+
for (let i = 0; i < count; i++) {
|
|
117
|
+
this.target_log.logs[this.task_index].task_detail.push({
|
|
118
|
+
index: i,
|
|
119
|
+
node: "",
|
|
120
|
+
message: [],
|
|
121
|
+
state: interface_1.ExecuteState.NONE
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (this.target_log.logs.length > this.task_index) {
|
|
125
|
+
this.target_log.logs[this.task_index].task_state.state = interface_1.ExecuteState.RUNNING;
|
|
126
|
+
this.target_log.logs[this.task_index].start_timer = Date.now();
|
|
127
|
+
this.target_log.dirty = true;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
execute_task_finish = (d) => {
|
|
131
|
+
if (this.target_log == undefined)
|
|
132
|
+
return;
|
|
133
|
+
if (this.target_log.logs.length > this.task_index) {
|
|
134
|
+
this.target_log.logs[this.task_index].task_state.state = interface_1.ExecuteState.FINISH;
|
|
135
|
+
this.target_log.logs[this.task_index].end_timer = Date.now();
|
|
136
|
+
this.target_log.dirty = true;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
execute_subtask_start = (d) => {
|
|
140
|
+
if (this.target_log == undefined)
|
|
141
|
+
return;
|
|
142
|
+
if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
|
|
143
|
+
this.target_log.logs[this.task_index].task_detail[d[1]].state = interface_1.ExecuteState.RUNNING;
|
|
144
|
+
this.target_log.dirty = true;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
execute_subtask_update = (d) => {
|
|
148
|
+
if (this.target_log == undefined)
|
|
149
|
+
return;
|
|
150
|
+
if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
|
|
151
|
+
this.target_log.logs[this.task_index].task_detail[d[1]].state = d[3];
|
|
152
|
+
this.target_log.dirty = true;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
execute_subtask_end = (d) => {
|
|
156
|
+
if (this.target_log == undefined)
|
|
157
|
+
return;
|
|
158
|
+
if (this.target_log.logs[this.task_index].task_detail.length > d[1]) {
|
|
159
|
+
this.target_log.logs[this.task_index].task_detail[d[1]].state = interface_1.ExecuteState.FINISH;
|
|
160
|
+
this.target_log.dirty = true;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
execute_job_start = (d) => {
|
|
164
|
+
};
|
|
165
|
+
execute_job_finish = (d) => {
|
|
166
|
+
if (this.target_log == undefined)
|
|
167
|
+
return;
|
|
168
|
+
if (d[3] == 1) {
|
|
169
|
+
const currentLog = this.target_log;
|
|
170
|
+
const task = currentLog.project.tasks[this.task_index];
|
|
171
|
+
const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
|
|
172
|
+
if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
|
|
173
|
+
const cr = task.jobs[index].number_args[0];
|
|
174
|
+
if (cr == interface_1.ConditionResult.None)
|
|
175
|
+
return;
|
|
176
|
+
const state = (cr == interface_1.ConditionResult.ThrowTask || cr == interface_1.ConditionResult.ThrowProject) ? interface_1.ExecuteState.ERROR : interface_1.ExecuteState.SKIP;
|
|
177
|
+
const target = this.model.record.task_detail[d[1]];
|
|
178
|
+
if (target != undefined) {
|
|
179
|
+
target.state = state;
|
|
180
|
+
}
|
|
181
|
+
currentLog.logs[this.task_index].task_state.state = state;
|
|
182
|
+
if (cr == interface_1.ConditionResult.Pause)
|
|
183
|
+
return;
|
|
184
|
+
if (cr == interface_1.ConditionResult.SkipProject || cr == interface_1.ConditionResult.ThrowProject) {
|
|
185
|
+
currentLog.state = state;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
feedback_message = (d) => {
|
|
191
|
+
if (this.target_log == undefined)
|
|
192
|
+
return;
|
|
193
|
+
if (d.index == undefined || d.index == -1)
|
|
194
|
+
return;
|
|
195
|
+
if (this.target_log == undefined)
|
|
196
|
+
return;
|
|
197
|
+
if (this.target_log.logs[this.task_index].task_detail.length > d.index) {
|
|
198
|
+
this.target_log.logs[this.task_index].task_detail[d.index].message.push(d.message);
|
|
199
|
+
this.target_log.dirty = true;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
console.warn("Try access message by index but failed: ", d);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
update_runtime_database = (d) => {
|
|
206
|
+
if (this.target_log != undefined) {
|
|
207
|
+
this.target_log.database = d;
|
|
208
|
+
this.target_log.dirty = true;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
getnewname = async (name) => {
|
|
212
|
+
const root = "data/log";
|
|
213
|
+
let count = 0;
|
|
214
|
+
let filename = name;
|
|
215
|
+
let p = `${root}/${filename}`;
|
|
216
|
+
while (fs.existsSync(p + ".json")) {
|
|
217
|
+
count = count + 1;
|
|
218
|
+
filename = `${name} ${count}`;
|
|
219
|
+
p = `${root}/${filename}`;
|
|
220
|
+
}
|
|
221
|
+
return filename;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
exports.Log_Proxy = Log_Proxy;
|
package/dist/server/detail.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { BusAnalysis,
|
|
1
|
+
import { BusAnalysis, ExecutePair, ExecuteProxy, ExecuteRecord, ExecuteState, Messager, Preference, Record, ShellFolder, Single, WebsocketPack } from "../interface";
|
|
2
2
|
import { PluginFeedback } from "./server";
|
|
3
3
|
import { MemoryData, RecordIOBase } from './io';
|
|
4
|
+
import { Console_Handler } from './detail/console_handle';
|
|
5
|
+
import { WebsocketManager } from '../script/socket_manager';
|
|
4
6
|
export interface BackendAction {
|
|
5
7
|
memory: MemoryData;
|
|
6
8
|
GetPreference: (uuid?: string) => Preference;
|
|
@@ -30,8 +32,8 @@ export interface ServerDetailEvent {
|
|
|
30
32
|
}
|
|
31
33
|
export declare class ServerDetail {
|
|
32
34
|
execute_manager: Array<ExecutePair>;
|
|
33
|
-
console:
|
|
34
|
-
websocket_manager:
|
|
35
|
+
console: Console_Handler;
|
|
36
|
+
websocket_manager: WebsocketManager | undefined;
|
|
35
37
|
shellBind: Map<any, any>;
|
|
36
38
|
loader: RecordIOBase | undefined;
|
|
37
39
|
backend: BackendAction;
|
|
@@ -47,7 +49,6 @@ export declare class ServerDetail {
|
|
|
47
49
|
Analysis: (d: BusAnalysis) => void;
|
|
48
50
|
shellReply: (data: Single, p?: WebsocketPack) => void;
|
|
49
51
|
folderReply: (data: ShellFolder, p?: WebsocketPack) => void;
|
|
50
|
-
console_update: () => any[];
|
|
51
52
|
resource_start: (socket: any, uuid: string) => void;
|
|
52
53
|
resource_end: (socket: any, uuid: string) => void;
|
|
53
54
|
plugin_info: (socket: any, uuid: string) => void;
|
|
@@ -68,5 +69,6 @@ export declare class ServerDetail {
|
|
|
68
69
|
console_clean: (socket: any, uuid: string) => void;
|
|
69
70
|
console_skip: (socket: any, uuid: string, forward: boolean, type: number, state?: ExecuteState) => void;
|
|
70
71
|
console_skip2: (socket: any, uuid: string, v: number) => void;
|
|
72
|
+
console_update: () => any[];
|
|
71
73
|
CombineProxy: (eps: Array<ExecuteProxy>) => ExecuteProxy;
|
|
72
74
|
}
|