verteilen-core 1.2.21 → 1.3.0
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/interface/base.d.ts +26 -12
- package/dist/interface/enum.d.ts +12 -5
- package/dist/interface/enum.js +14 -6
- package/dist/interface/struct.d.ts +9 -1
- package/dist/interface.d.ts +1 -1
- package/dist/interface.js +1 -1
- package/dist/script/execute/base.d.ts +8 -6
- package/dist/script/execute/base.js +21 -8
- package/dist/script/execute/index.d.ts +8 -0
- package/dist/script/execute/index.js +24 -0
- package/dist/script/execute/region_job.d.ts +9 -1
- package/dist/script/execute/region_job.js +62 -2
- package/dist/script/execute/region_project.d.ts +3 -3
- package/dist/script/execute/region_project.js +31 -6
- package/dist/script/execute/region_subtask.d.ts +8 -1
- package/dist/script/execute/region_subtask.js +37 -2
- package/dist/script/execute/region_task.d.ts +32 -4
- package/dist/script/execute/region_task.js +270 -8
- package/dist/script/execute/runner.d.ts +1 -10
- package/dist/script/execute/runner.js +0 -242
- package/dist/script/execute_manager.js +55 -53
- package/dist/server/detail.js +7 -7
- package/dist/server/io.d.ts +5 -1
- package/dist/server/io.js +13 -5
- package/dist/server/module/project.d.ts +14 -0
- package/dist/server/module/project.js +64 -0
- package/dist/server/module/service.d.ts +5 -0
- package/dist/server/module/service.js +10 -0
- package/dist/server/plugin.js +3 -3
- package/dist/server/server.d.ts +7 -2
- package/dist/server/server.js +7 -0
- package/dist/util/console_handle.js +8 -8
- package/dist/util/log_handle.js +4 -4
- package/package.json +1 -1
- package/src/interface/base.ts +104 -31
- package/src/interface/enum.ts +6 -2
- package/src/interface/struct.ts +11 -1
- package/src/interface.ts +1 -1
- package/src/script/execute/base.ts +45 -29
- package/src/script/execute/feedback.ts +1 -3
- package/src/script/execute/region_job.ts +66 -2
- package/src/script/execute/region_project.ts +42 -5
- package/src/script/execute/region_subtask.ts +36 -2
- package/src/script/execute/region_task.ts +348 -9
- package/src/script/execute/runner.ts +1 -306
- package/src/script/execute_manager.ts +61 -61
- package/src/server/detail.ts +12 -7
- package/src/server/io.ts +29 -6
- package/src/server/module/project.ts +82 -0
- package/src/server/module/service.ts +14 -0
- package/src/server/plugin.ts +12 -3
- package/src/server/server.ts +39 -3
- package/src/util/console_handle.ts +8 -8
- package/src/util/log_handle.ts +4 -4
- /package/src/script/execute/{interface.ts → index.ts} +0 -0
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExecuteManager = void 0;
|
|
4
4
|
const interface_1 = require("../interface");
|
|
5
|
+
const region_project_1 = require("./execute/region_project");
|
|
6
|
+
const region_task_1 = require("./execute/region_task");
|
|
5
7
|
const runner_1 = require("./execute/runner");
|
|
6
8
|
class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
7
9
|
Update = () => {
|
|
8
10
|
if (this.state != interface_1.ExecuteState.RUNNING)
|
|
9
11
|
return;
|
|
10
|
-
else if (this.
|
|
11
|
-
this.
|
|
12
|
-
this.messager_log(`[Execute] Project Start ${this.
|
|
13
|
-
this.proxy?.executeProjectStart([this.
|
|
14
|
-
this.SyncDatabase(this.
|
|
12
|
+
else if (this.runner == undefined && this.current_projects.length > 0) {
|
|
13
|
+
this.runner = new region_project_1.Region_Project(this, this.current_projects[0]);
|
|
14
|
+
this.messager_log(`[Execute] Project Start ${this.runner.project.uuid}`);
|
|
15
|
+
this.proxy?.executeProjectStart([this.runner.project, 0]);
|
|
16
|
+
this.SyncDatabase(this.runner.project);
|
|
15
17
|
}
|
|
16
|
-
else if (this.
|
|
18
|
+
else if (this.runner != undefined) {
|
|
17
19
|
if (this.first)
|
|
18
20
|
this.first = false;
|
|
19
|
-
this.
|
|
21
|
+
this.runner.RUN();
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
Stop = () => {
|
|
@@ -48,7 +50,7 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
48
50
|
this.messager_log(`[Execute] Node count should be bigger than one`);
|
|
49
51
|
return -1;
|
|
50
52
|
}
|
|
51
|
-
if (this.current_projects.map(x => x.
|
|
53
|
+
if (this.current_projects.map(x => x.tasks.length).reduce((acc, cur) => acc + cur, 0) == 0) {
|
|
52
54
|
this.messager_log(`[Execute] No task can be executing`);
|
|
53
55
|
return -1;
|
|
54
56
|
}
|
|
@@ -64,7 +66,7 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
64
66
|
this.messager_log(`[Execute] Init successfully, Enter process right now, length: ${this.current_projects.length}`);
|
|
65
67
|
let i = 0;
|
|
66
68
|
for (const x of this.current_projects) {
|
|
67
|
-
if (x.
|
|
69
|
+
if (x.tasks.length > 0) {
|
|
68
70
|
break;
|
|
69
71
|
}
|
|
70
72
|
else {
|
|
@@ -75,12 +77,8 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
75
77
|
};
|
|
76
78
|
Clean = () => {
|
|
77
79
|
this.current_projects = [];
|
|
78
|
-
this.
|
|
79
|
-
this.current_t = undefined;
|
|
80
|
-
this.current_cron = [];
|
|
81
|
-
this.current_job = [];
|
|
80
|
+
this.runner = undefined;
|
|
82
81
|
this.current_nodes = [];
|
|
83
|
-
this.current_multithread = 1;
|
|
84
82
|
this.state = interface_1.ExecuteState.NONE;
|
|
85
83
|
};
|
|
86
84
|
Release = () => {
|
|
@@ -122,7 +120,8 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
122
120
|
if (this.current_t == undefined)
|
|
123
121
|
return;
|
|
124
122
|
if (this.current_job.length > 0) {
|
|
125
|
-
this.
|
|
123
|
+
if (this.runner?.runner)
|
|
124
|
+
this.runner.runner.job = [];
|
|
126
125
|
this.proxy?.executeSubtaskUpdate([this.current_t, 0, '', interface_1.ExecuteState.NONE]);
|
|
127
126
|
}
|
|
128
127
|
else if (this.current_cron.length > 0) {
|
|
@@ -190,7 +189,7 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
190
189
|
}
|
|
191
190
|
};
|
|
192
191
|
skipProjectFirst = () => {
|
|
193
|
-
this.
|
|
192
|
+
this.runner = new region_project_1.Region_Project(this, this.current_projects[1]);
|
|
194
193
|
this.proxy?.executeProjectStart([this.current_p, 1]);
|
|
195
194
|
this.SyncDatabase(this.current_p);
|
|
196
195
|
this.state = interface_1.ExecuteState.RUNNING;
|
|
@@ -203,14 +202,12 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
203
202
|
const atend = forward ? index == this.current_projects.length - 1 : index == 0;
|
|
204
203
|
if (atend) {
|
|
205
204
|
if (forward) {
|
|
206
|
-
this.
|
|
207
|
-
this.current_t = undefined;
|
|
205
|
+
this.runner = undefined;
|
|
208
206
|
this.state = interface_1.ExecuteState.FINISH;
|
|
209
207
|
this.messager_log(`[Execute] Skip project to Finish !`);
|
|
210
208
|
}
|
|
211
209
|
else {
|
|
212
|
-
this.
|
|
213
|
-
this.current_t = undefined;
|
|
210
|
+
this.runner = new region_project_1.Region_Project(this, this.current_projects[0]);
|
|
214
211
|
this.state = interface_1.ExecuteState.RUNNING;
|
|
215
212
|
this.messager_log(`[Execute] Previous project to Begining !`);
|
|
216
213
|
}
|
|
@@ -218,8 +215,7 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
218
215
|
}
|
|
219
216
|
else {
|
|
220
217
|
const next = forward ? this.current_projects[index + 1] : this.current_projects[index - 1];
|
|
221
|
-
this.
|
|
222
|
-
this.current_t = undefined;
|
|
218
|
+
this.runner = new region_project_1.Region_Project(this, next);
|
|
223
219
|
this.state = interface_1.ExecuteState.RUNNING;
|
|
224
220
|
if (forward) {
|
|
225
221
|
this.messager_log(`[Execute] Skip project ${index}. ${this.current_p.uuid}`);
|
|
@@ -233,11 +229,11 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
233
229
|
}
|
|
234
230
|
};
|
|
235
231
|
skipTaskFirst = () => {
|
|
236
|
-
if (this.current_p.
|
|
237
|
-
this.
|
|
232
|
+
if (this.current_p.tasks.length > 0 && this.runner != undefined) {
|
|
233
|
+
this.runner.runner = new region_task_1.Region_Task(this, this.current_p.tasks[0]);
|
|
238
234
|
const taskCount = this.get_task_state_count(this.current_t);
|
|
239
|
-
if (this.current_t
|
|
240
|
-
this.Init_CronContainer(
|
|
235
|
+
if (this.current_t?.cronjob) {
|
|
236
|
+
this.runner.runner?.Init_CronContainer(taskCount);
|
|
241
237
|
}
|
|
242
238
|
this.t_state = interface_1.ExecuteState.NONE;
|
|
243
239
|
this.proxy?.executeTaskStart([this.current_t, taskCount]);
|
|
@@ -250,47 +246,53 @@ class ExecuteManager extends runner_1.ExecuteManager_Runner {
|
|
|
250
246
|
};
|
|
251
247
|
previousTaskFirst = () => {
|
|
252
248
|
const index = this.current_projects.findIndex(x => x.uuid == this.current_p.uuid);
|
|
253
|
-
if (index == 0) {
|
|
254
|
-
this.
|
|
249
|
+
if (index == 0 && this.runner != undefined) {
|
|
250
|
+
this.runner.runner = undefined;
|
|
255
251
|
}
|
|
256
252
|
else {
|
|
257
|
-
this.
|
|
258
|
-
this.messager_log(`[Execute] Previous task ${index}. Jump Project: ${this.current_p
|
|
253
|
+
this.runner = new region_project_1.Region_Project(this, this.current_projects[index - 1]);
|
|
254
|
+
this.messager_log(`[Execute] Previous task ${index}. Jump Project: ${this.current_p?.uuid}`);
|
|
259
255
|
}
|
|
260
|
-
this.
|
|
256
|
+
if (this.runner?.runner)
|
|
257
|
+
this.runner.runner.job = [];
|
|
261
258
|
this.t_state = interface_1.ExecuteState.NONE;
|
|
262
259
|
return index;
|
|
263
260
|
};
|
|
264
261
|
skipTask = () => {
|
|
265
|
-
const index = this.current_p.
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
262
|
+
const index = this.current_p.tasks.findIndex(x => x.uuid == this.current_t.uuid);
|
|
263
|
+
if (this.runner) {
|
|
264
|
+
if (index == this.current_p.tasks.length - 1) {
|
|
265
|
+
this.proxy?.executeTaskFinish(this.current_t);
|
|
266
|
+
this.runner.runner = undefined;
|
|
267
|
+
this.messager_log(`[Execute] Skip task to Finish !`);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
this.proxy?.executeTaskFinish(this.current_t);
|
|
271
|
+
this.runner.runner = new region_task_1.Region_Task(this, this.current_p.tasks[index + 1]);
|
|
272
|
+
this.messager_log(`[Execute] Skip task ${index}. ${this.current_t.uuid}`);
|
|
273
|
+
const taskCount = this.get_task_state_count(this.current_t);
|
|
274
|
+
if (this.current_t.cronjob) {
|
|
275
|
+
this.runner.runner.Init_CronContainer(taskCount);
|
|
276
|
+
}
|
|
277
|
+
this.proxy?.executeTaskStart([this.current_t, taskCount]);
|
|
278
278
|
}
|
|
279
|
-
this.proxy?.executeTaskStart([this.current_t, taskCount]);
|
|
280
279
|
}
|
|
281
|
-
this.
|
|
280
|
+
if (this.runner?.runner)
|
|
281
|
+
this.runner.runner.job = [];
|
|
282
282
|
this.t_state = interface_1.ExecuteState.NONE;
|
|
283
283
|
return index;
|
|
284
284
|
};
|
|
285
285
|
previousTask = () => {
|
|
286
|
-
const index = this.current_p.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
286
|
+
const index = this.current_p.tasks.findIndex(x => x.uuid == this.current_t.uuid);
|
|
287
|
+
if (this.runner?.runner) {
|
|
288
|
+
this.runner.runner = new region_task_1.Region_Task(this, this.current_p.tasks[index - 1]);
|
|
289
|
+
const taskCount = this.get_task_state_count(this.current_t);
|
|
290
|
+
if (this.current_t.cronjob) {
|
|
291
|
+
this.runner.runner.Init_CronContainer(taskCount);
|
|
292
|
+
}
|
|
293
|
+
this.t_state = interface_1.ExecuteState.NONE;
|
|
294
|
+
this.proxy?.executeTaskStart([this.current_t, taskCount]);
|
|
291
295
|
}
|
|
292
|
-
this.t_state = interface_1.ExecuteState.NONE;
|
|
293
|
-
this.proxy?.executeTaskStart([this.current_t, taskCount]);
|
|
294
296
|
return 0;
|
|
295
297
|
};
|
|
296
298
|
}
|
package/dist/server/detail.js
CHANGED
|
@@ -64,7 +64,7 @@ class ServerDetail {
|
|
|
64
64
|
message: `${x.websocket.url} \n${x.uuid}`
|
|
65
65
|
};
|
|
66
66
|
if (this.feedback.electron) {
|
|
67
|
-
this.feedback.electron('makeToast', p);
|
|
67
|
+
this.feedback.electron()?.send('makeToast', p);
|
|
68
68
|
}
|
|
69
69
|
if (this.feedback.socket && this.backend.Boradcasting) {
|
|
70
70
|
this.backend.Boradcasting('makeToast', p);
|
|
@@ -80,7 +80,7 @@ class ServerDetail {
|
|
|
80
80
|
message: `${x.websocket.url} \n${x.uuid}`
|
|
81
81
|
};
|
|
82
82
|
if (this.feedback.electron) {
|
|
83
|
-
this.feedback.electron('makeToast', p);
|
|
83
|
+
this.feedback.electron()?.send('makeToast', p);
|
|
84
84
|
}
|
|
85
85
|
if (this.feedback.socket && this.backend.Boradcasting) {
|
|
86
86
|
this.backend.Boradcasting('makeToast', p);
|
|
@@ -94,7 +94,7 @@ class ServerDetail {
|
|
|
94
94
|
};
|
|
95
95
|
shellReply = (data, p) => {
|
|
96
96
|
if (this.feedback.electron) {
|
|
97
|
-
this.feedback.electron("shellReply", data);
|
|
97
|
+
this.feedback.electron()?.send("shellReply", data);
|
|
98
98
|
}
|
|
99
99
|
if (this.feedback.socket) {
|
|
100
100
|
if (p == undefined)
|
|
@@ -110,7 +110,7 @@ class ServerDetail {
|
|
|
110
110
|
};
|
|
111
111
|
folderReply = (data, p) => {
|
|
112
112
|
if (this.feedback.electron) {
|
|
113
|
-
this.feedback.electron("folderReply", data);
|
|
113
|
+
this.feedback.electron()?.send("folderReply", data);
|
|
114
114
|
}
|
|
115
115
|
if (this.feedback.socket) {
|
|
116
116
|
if (p == undefined)
|
|
@@ -371,7 +371,7 @@ class ServerDetail {
|
|
|
371
371
|
if (target.record.project_index < 0) {
|
|
372
372
|
target.record.project_index = 0;
|
|
373
373
|
}
|
|
374
|
-
target.record.task_state = target.record.projects[target.record.project_index].
|
|
374
|
+
target.record.task_state = target.record.projects[target.record.project_index].tasks.map(x => {
|
|
375
375
|
return {
|
|
376
376
|
uuid: x.uuid,
|
|
377
377
|
state: interface_1.ExecuteState.NONE
|
|
@@ -379,7 +379,7 @@ class ServerDetail {
|
|
|
379
379
|
});
|
|
380
380
|
target.record.task_detail = [];
|
|
381
381
|
const p = target.record.projects[target.record.project_index];
|
|
382
|
-
const t = p.
|
|
382
|
+
const t = p.tasks[target.record.task_index];
|
|
383
383
|
const count = target.manager.get_task_state_count(t);
|
|
384
384
|
for (let i = 0; i < count; i++) {
|
|
385
385
|
target.record.task_detail.push({
|
|
@@ -410,7 +410,7 @@ class ServerDetail {
|
|
|
410
410
|
target.record.task_state[target.record.task_index].state = interface_1.ExecuteState.RUNNING;
|
|
411
411
|
target.record.task_detail = [];
|
|
412
412
|
const p = target.record.projects[target.record.project_index];
|
|
413
|
-
const t = p.
|
|
413
|
+
const t = p.tasks[target.record.task_index];
|
|
414
414
|
const count = target.manager.get_task_state_count(t);
|
|
415
415
|
for (let i = 0; i < count; i++) {
|
|
416
416
|
target.record.task_detail.push({
|
package/dist/server/io.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Project, RecordType, Database, UserProfile, Library, ExecutionLog, Node } from "../interface";
|
|
1
|
+
import { Project, RecordType, Database, UserProfile, Library, ExecutionLog, Node, Task, Job } from "../interface";
|
|
2
2
|
export interface MemoryData {
|
|
3
3
|
projects: Array<Project>;
|
|
4
|
+
tasks: Array<Task>;
|
|
5
|
+
jobs: Array<Job>;
|
|
4
6
|
database: Array<Database>;
|
|
5
7
|
nodes: Array<Node>;
|
|
6
8
|
logs: Array<ExecutionLog>;
|
|
@@ -18,6 +20,8 @@ export interface RecordIOLoader {
|
|
|
18
20
|
}
|
|
19
21
|
export interface RecordLoader {
|
|
20
22
|
project: RecordIOLoader;
|
|
23
|
+
task: RecordIOLoader;
|
|
24
|
+
job: RecordIOLoader;
|
|
21
25
|
database: RecordIOLoader;
|
|
22
26
|
node: RecordIOLoader;
|
|
23
27
|
log: RecordIOLoader;
|
package/dist/server/io.js
CHANGED
|
@@ -7,7 +7,9 @@ const _CreateRecordMemoryLoader = (loader, type) => {
|
|
|
7
7
|
switch (type) {
|
|
8
8
|
default:
|
|
9
9
|
case interface_1.RecordType.PROJECT: return loader.projects;
|
|
10
|
-
case interface_1.RecordType.
|
|
10
|
+
case interface_1.RecordType.TASK: return loader.tasks;
|
|
11
|
+
case interface_1.RecordType.JOB: return loader.jobs;
|
|
12
|
+
case interface_1.RecordType.DATABASE: return loader.database;
|
|
11
13
|
case interface_1.RecordType.NODE: return loader.nodes;
|
|
12
14
|
case interface_1.RecordType.LOG: return loader.logs;
|
|
13
15
|
case interface_1.RecordType.LIB: return loader.libs;
|
|
@@ -58,7 +60,9 @@ const _CreateRecordIOLoader = (loader, memory, type, folder, ext = ".json") => {
|
|
|
58
60
|
switch (type) {
|
|
59
61
|
default:
|
|
60
62
|
case interface_1.RecordType.PROJECT: return memory.projects;
|
|
61
|
-
case interface_1.RecordType.
|
|
63
|
+
case interface_1.RecordType.TASK: return memory.tasks;
|
|
64
|
+
case interface_1.RecordType.JOB: return memory.jobs;
|
|
65
|
+
case interface_1.RecordType.DATABASE: return memory.database;
|
|
62
66
|
case interface_1.RecordType.NODE: return memory.nodes;
|
|
63
67
|
case interface_1.RecordType.LOG: return memory.logs;
|
|
64
68
|
case interface_1.RecordType.LIB: return memory.libs;
|
|
@@ -148,7 +152,9 @@ exports._CreateRecordIOLoader = _CreateRecordIOLoader;
|
|
|
148
152
|
const CreateRecordMemoryLoader = (loader) => {
|
|
149
153
|
return {
|
|
150
154
|
project: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.PROJECT),
|
|
151
|
-
|
|
155
|
+
task: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.TASK),
|
|
156
|
+
job: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.JOB),
|
|
157
|
+
database: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.DATABASE),
|
|
152
158
|
node: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.NODE),
|
|
153
159
|
log: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.LOG),
|
|
154
160
|
lib: (0, exports._CreateRecordMemoryLoader)(loader, interface_1.RecordType.LIB),
|
|
@@ -158,8 +164,10 @@ const CreateRecordMemoryLoader = (loader) => {
|
|
|
158
164
|
exports.CreateRecordMemoryLoader = CreateRecordMemoryLoader;
|
|
159
165
|
const CreateRecordIOLoader = (loader, memory) => {
|
|
160
166
|
return {
|
|
161
|
-
project: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.PROJECT, "
|
|
162
|
-
|
|
167
|
+
project: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.PROJECT, "project"),
|
|
168
|
+
task: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.TASK, "task"),
|
|
169
|
+
job: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.JOB, "job"),
|
|
170
|
+
database: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.DATABASE, "database"),
|
|
163
171
|
node: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.NODE, "node"),
|
|
164
172
|
log: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.LOG, "log"),
|
|
165
173
|
lib: (0, exports._CreateRecordIOLoader)(loader, memory, interface_1.RecordType.LIB, "lib", ""),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Project, Task } from "../../interface";
|
|
2
|
+
import { MemoryData, RecordLoader } from "../io";
|
|
3
|
+
import { Server } from "../server";
|
|
4
|
+
export declare class Project_Module {
|
|
5
|
+
server: Server;
|
|
6
|
+
constructor(memory: Server);
|
|
7
|
+
get memory(): MemoryData;
|
|
8
|
+
get loader(): RecordLoader;
|
|
9
|
+
ProjectJobCount(uuid: string): number;
|
|
10
|
+
PopulateProject(uuid: string): Project | undefined;
|
|
11
|
+
PopulateTask(uuid: string): Task | undefined;
|
|
12
|
+
CascadeDeleteProject(uuid: string): void;
|
|
13
|
+
CascadeDeleteTask(uuid: string): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Project_Module = void 0;
|
|
4
|
+
class Project_Module {
|
|
5
|
+
server;
|
|
6
|
+
constructor(memory) {
|
|
7
|
+
this.server = memory;
|
|
8
|
+
}
|
|
9
|
+
get memory() { return this.server.memory; }
|
|
10
|
+
get loader() { return this.server.current_loader; }
|
|
11
|
+
ProjectJobCount(uuid) {
|
|
12
|
+
const p = this.memory.projects.find(p => p.uuid == uuid);
|
|
13
|
+
if (!p)
|
|
14
|
+
return 0;
|
|
15
|
+
const t = p.tasks_uuid.map(t_uuid => this.memory.tasks.find(t => t.uuid == t_uuid)).filter(t => t != undefined);
|
|
16
|
+
const counts = t.map(x => x.jobs_uuid.length);
|
|
17
|
+
return counts.reduce((a, b) => a + b, 0);
|
|
18
|
+
}
|
|
19
|
+
PopulateProject(uuid) {
|
|
20
|
+
const p = this.memory.projects.find(p => p.uuid == uuid);
|
|
21
|
+
if (!p)
|
|
22
|
+
return undefined;
|
|
23
|
+
const buffer = Object.assign({}, p);
|
|
24
|
+
for (var x of buffer.tasks_uuid) {
|
|
25
|
+
const t = this.PopulateTask(x);
|
|
26
|
+
if (!t)
|
|
27
|
+
return undefined;
|
|
28
|
+
buffer.tasks.push(t);
|
|
29
|
+
}
|
|
30
|
+
return buffer;
|
|
31
|
+
}
|
|
32
|
+
PopulateTask(uuid) {
|
|
33
|
+
const p = this.memory.tasks.find(p => p.uuid == uuid);
|
|
34
|
+
if (!p)
|
|
35
|
+
return undefined;
|
|
36
|
+
const buffer = Object.assign({}, p);
|
|
37
|
+
for (var x of buffer.jobs_uuid) {
|
|
38
|
+
const t = this.memory.jobs.find(t => t.uuid == x);
|
|
39
|
+
if (!t)
|
|
40
|
+
return undefined;
|
|
41
|
+
buffer.jobs.push(t);
|
|
42
|
+
}
|
|
43
|
+
return buffer;
|
|
44
|
+
}
|
|
45
|
+
CascadeDeleteProject(uuid) {
|
|
46
|
+
const p = this.memory.projects.find(p => p.uuid == uuid);
|
|
47
|
+
if (!p)
|
|
48
|
+
return;
|
|
49
|
+
p.tasks_uuid.forEach(t_uuid => {
|
|
50
|
+
this.CascadeDeleteTask(t_uuid);
|
|
51
|
+
});
|
|
52
|
+
this.loader.project.delete(p.uuid);
|
|
53
|
+
}
|
|
54
|
+
CascadeDeleteTask(uuid) {
|
|
55
|
+
const p = this.memory.tasks.find(p => p.uuid == uuid);
|
|
56
|
+
if (!p)
|
|
57
|
+
return;
|
|
58
|
+
p.jobs_uuid.forEach(j_uuid => {
|
|
59
|
+
this.loader.job.delete(j_uuid);
|
|
60
|
+
});
|
|
61
|
+
this.loader.task.delete(p.uuid);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.Project_Module = Project_Module;
|
package/dist/server/plugin.js
CHANGED
|
@@ -133,7 +133,7 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
133
133
|
const p = { title: "Import Failed", type: "error", message: `Cannot find the json from url ${url}, or maybe just the wrong token` };
|
|
134
134
|
const h = { name: "makeToast", data: JSON.stringify(p) };
|
|
135
135
|
if (feedback.electron) {
|
|
136
|
-
feedback.electron("makeToast", JSON.stringify(p));
|
|
136
|
+
feedback.electron()?.send("makeToast", JSON.stringify(p));
|
|
137
137
|
}
|
|
138
138
|
if (feedback.socket) {
|
|
139
139
|
feedback.socket(JSON.stringify(h));
|
|
@@ -189,7 +189,7 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
189
189
|
const p = { title: x[0], type: "error", message: x[1] };
|
|
190
190
|
const h = { name: "makeToast", data: JSON.stringify(p) };
|
|
191
191
|
if (feedback.electron) {
|
|
192
|
-
feedback.electron("makeToast", JSON.stringify(p));
|
|
192
|
+
feedback.electron()?.send("makeToast", JSON.stringify(p));
|
|
193
193
|
}
|
|
194
194
|
if (feedback.socket) {
|
|
195
195
|
feedback.socket(JSON.stringify(h));
|
|
@@ -237,7 +237,7 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
|
|
|
237
237
|
const p = { title: "Import Failed", type: "error", message: `Cannot find the json from url ${url}, or maybe just the wrong token` };
|
|
238
238
|
const h = { name: "makeToast", data: JSON.stringify(p) };
|
|
239
239
|
if (feedback.electron) {
|
|
240
|
-
feedback.electron("makeToast", JSON.stringify(p));
|
|
240
|
+
feedback.electron()?.send("makeToast", JSON.stringify(p));
|
|
241
241
|
}
|
|
242
242
|
if (feedback.socket) {
|
|
243
243
|
feedback.socket(JSON.stringify(h));
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Execute_ConsoleServerManager, PluginPageData } from "../interface";
|
|
2
2
|
import { ServerDetail } from "./detail";
|
|
3
3
|
import { MemoryData, RecordIOBase, RecordLoader } from "./io";
|
|
4
|
+
import { Project_Module } from "./module/project";
|
|
4
5
|
import { PluginLoader } from "./plugin";
|
|
5
|
-
export type
|
|
6
|
+
export type Caller_Electron_Send = (channel: string, ...args: any[]) => void;
|
|
7
|
+
export interface Caller_Electron {
|
|
8
|
+
send: Caller_Electron_Send;
|
|
9
|
+
}
|
|
6
10
|
export type Caller_Socket = (data: any) => void;
|
|
7
11
|
export type TypeMap = {
|
|
8
12
|
[key: string]: Function;
|
|
9
13
|
};
|
|
10
14
|
export interface PluginFeedback {
|
|
11
|
-
electron: Caller_Electron | undefined;
|
|
15
|
+
electron: (() => (Caller_Electron | undefined)) | undefined;
|
|
12
16
|
socket: Caller_Socket | undefined;
|
|
13
17
|
}
|
|
14
18
|
export declare class Server {
|
|
@@ -20,6 +24,7 @@ export declare class Server {
|
|
|
20
24
|
plugin_loader: PluginLoader | undefined;
|
|
21
25
|
memory_loader: RecordLoader;
|
|
22
26
|
detail: ServerDetail | undefined;
|
|
27
|
+
module_project: Project_Module;
|
|
23
28
|
constructor();
|
|
24
29
|
get current_loader(): RecordLoader;
|
|
25
30
|
LoadFromDisk: () => Promise<Array<Array<string>>>;
|
package/dist/server/server.js
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Server = void 0;
|
|
4
4
|
const io_1 = require("./io");
|
|
5
|
+
const project_1 = require("./module/project");
|
|
5
6
|
class Server {
|
|
6
7
|
manager = [];
|
|
7
8
|
memory = {
|
|
8
9
|
projects: [],
|
|
10
|
+
tasks: [],
|
|
11
|
+
jobs: [],
|
|
9
12
|
database: [],
|
|
10
13
|
nodes: [],
|
|
11
14
|
logs: [],
|
|
@@ -21,8 +24,10 @@ class Server {
|
|
|
21
24
|
plugin_loader = undefined;
|
|
22
25
|
memory_loader;
|
|
23
26
|
detail;
|
|
27
|
+
module_project;
|
|
24
28
|
constructor() {
|
|
25
29
|
this.memory_loader = (0, io_1.CreateRecordMemoryLoader)(this.memory);
|
|
30
|
+
this.module_project = new project_1.Project_Module(this);
|
|
26
31
|
}
|
|
27
32
|
get current_loader() {
|
|
28
33
|
if (this.loader)
|
|
@@ -32,6 +37,8 @@ class Server {
|
|
|
32
37
|
LoadFromDisk = () => {
|
|
33
38
|
const ts = [
|
|
34
39
|
this.current_loader.project.load_all(),
|
|
40
|
+
this.current_loader.task.load_all(),
|
|
41
|
+
this.current_loader.job.load_all(),
|
|
35
42
|
this.current_loader.database.load_all(),
|
|
36
43
|
this.current_loader.node.load_all(),
|
|
37
44
|
this.current_loader.log.load_all(),
|
|
@@ -21,7 +21,7 @@ class Util_Server_Console {
|
|
|
21
21
|
model.record.project_index = pass;
|
|
22
22
|
model.record.project = record.projects[pass].uuid;
|
|
23
23
|
model.record.task_index = 0;
|
|
24
|
-
model.record.task_state = model.record.projects[0].
|
|
24
|
+
model.record.task_state = model.record.projects[0].tasks.map(x => {
|
|
25
25
|
return {
|
|
26
26
|
uuid: x.uuid,
|
|
27
27
|
state: interface_1.ExecuteState.NONE
|
|
@@ -29,7 +29,7 @@ class Util_Server_Console {
|
|
|
29
29
|
});
|
|
30
30
|
model.record.task_state[0].state = interface_1.ExecuteState.RUNNING;
|
|
31
31
|
model.record.task_detail = [];
|
|
32
|
-
const task = model.record.projects[model.record.project_index]?.
|
|
32
|
+
const task = model.record.projects[model.record.project_index]?.tasks[model.record.task_index];
|
|
33
33
|
const count = task.cronjob ? (task?.jobs.length ?? 0) : 1;
|
|
34
34
|
for (let i = 0; i < count; i++) {
|
|
35
35
|
model.record.task_detail.push({
|
|
@@ -72,14 +72,14 @@ class Util_Server_Console_Proxy {
|
|
|
72
72
|
this.model.record.project = d[0].uuid;
|
|
73
73
|
this.model.record.project_index = index;
|
|
74
74
|
this.model.record.project_state[index].state = interface_1.ExecuteState.RUNNING;
|
|
75
|
-
this.model.record.task_state = this.model.record.projects[index].
|
|
75
|
+
this.model.record.task_state = this.model.record.projects[index].tasks.map(x => {
|
|
76
76
|
return {
|
|
77
77
|
uuid: x.uuid,
|
|
78
78
|
state: interface_1.ExecuteState.NONE
|
|
79
79
|
};
|
|
80
80
|
});
|
|
81
81
|
this.model.record.task_detail = [];
|
|
82
|
-
const task = this.model.record.projects[this.model.record.project_index]?.
|
|
82
|
+
const task = this.model.record.projects[this.model.record.project_index]?.tasks[this.model.record.task_index];
|
|
83
83
|
const count = task.cronjob ? (task?.jobs.length ?? 0) : 1;
|
|
84
84
|
for (let i = 0; i < count; i++) {
|
|
85
85
|
this.model.record.task_detail.push({
|
|
@@ -111,7 +111,7 @@ class Util_Server_Console_Proxy {
|
|
|
111
111
|
execute_task_start = (d) => {
|
|
112
112
|
if (this.model.record.project_index == -1)
|
|
113
113
|
return;
|
|
114
|
-
const index = this.model.record.projects[this.model.record.project_index].
|
|
114
|
+
const index = this.model.record.projects[this.model.record.project_index].tasks.findIndex(x => x.uuid == d[0].uuid);
|
|
115
115
|
if (index == -1)
|
|
116
116
|
return;
|
|
117
117
|
this.model.record.useCron = d[0].cronjob;
|
|
@@ -124,7 +124,7 @@ class Util_Server_Console_Proxy {
|
|
|
124
124
|
this.model.record.task_state[i].state = interface_1.ExecuteState.NONE;
|
|
125
125
|
this.model.record.task_detail = [];
|
|
126
126
|
const p = this.model.record.projects[this.model.record.project_index];
|
|
127
|
-
const t = p.
|
|
127
|
+
const t = p.tasks[this.model.record.task_index];
|
|
128
128
|
const count = this.model.manager.get_task_state_count(t);
|
|
129
129
|
for (let i = 0; i < count; i++) {
|
|
130
130
|
this.model.record.task_detail.push({
|
|
@@ -142,7 +142,7 @@ class Util_Server_Console_Proxy {
|
|
|
142
142
|
}
|
|
143
143
|
if (this.model.record.project_index == -1)
|
|
144
144
|
return;
|
|
145
|
-
const index = this.model.record.projects[this.model.record.project_index].
|
|
145
|
+
const index = this.model.record.projects[this.model.record.project_index].tasks.findIndex(x => x.uuid == d.uuid);
|
|
146
146
|
if (index == -1)
|
|
147
147
|
return;
|
|
148
148
|
this.model.record.useCron = false;
|
|
@@ -187,7 +187,7 @@ class Util_Server_Console_Proxy {
|
|
|
187
187
|
};
|
|
188
188
|
execute_job_finish = (d) => {
|
|
189
189
|
if (d[3] == 1) {
|
|
190
|
-
const task = this.model.record.projects[this.model.record.project_index].
|
|
190
|
+
const task = this.model.record.projects[this.model.record.project_index].tasks[this.model.record.task_index];
|
|
191
191
|
const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
|
|
192
192
|
if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
|
|
193
193
|
const cr = task.jobs[index].number_args[0];
|
package/dist/util/log_handle.js
CHANGED
|
@@ -81,7 +81,7 @@ class Util_Server_Log_Proxy {
|
|
|
81
81
|
start_timer: Date.now(),
|
|
82
82
|
database: d[0].database,
|
|
83
83
|
end_timer: 0,
|
|
84
|
-
logs: target.
|
|
84
|
+
logs: target.tasks.map(x => {
|
|
85
85
|
return {
|
|
86
86
|
start_timer: 0,
|
|
87
87
|
end_timer: 0,
|
|
@@ -105,13 +105,13 @@ class Util_Server_Log_Proxy {
|
|
|
105
105
|
execute_task_start = (d) => {
|
|
106
106
|
if (this.target_log == undefined)
|
|
107
107
|
return;
|
|
108
|
-
const index = this.target_log.project.
|
|
108
|
+
const index = this.target_log.project.tasks.findIndex(x => x.uuid == d[0].uuid);
|
|
109
109
|
if (index == -1)
|
|
110
110
|
return;
|
|
111
111
|
this.task_index = index;
|
|
112
112
|
this.target_log.logs[this.task_index].task_detail = [];
|
|
113
113
|
const p = this.model.record.projects[this.model.record.project_index];
|
|
114
|
-
const t = p.
|
|
114
|
+
const t = p.tasks[this.task_index];
|
|
115
115
|
const count = this.model.manager.get_task_state_count(t);
|
|
116
116
|
for (let i = 0; i < count; i++) {
|
|
117
117
|
this.target_log.logs[this.task_index].task_detail.push({
|
|
@@ -167,7 +167,7 @@ class Util_Server_Log_Proxy {
|
|
|
167
167
|
return;
|
|
168
168
|
if (d[3] == 1) {
|
|
169
169
|
const currentLog = this.target_log;
|
|
170
|
-
const task = currentLog.project.
|
|
170
|
+
const task = currentLog.project.tasks[this.task_index];
|
|
171
171
|
const index = task.jobs.findIndex(x => x.uuid == d[0].uuid);
|
|
172
172
|
if (index != -1 && task.jobs[index].category == interface_1.JobCategory.Condition) {
|
|
173
173
|
const cr = task.jobs[index].number_args[0];
|