verteilen-core 1.4.21 → 1.4.22
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 +0 -17
- package/dist/client/analysis.js +0 -22
- package/dist/client/client.d.ts +0 -17
- package/dist/client/client.js +4 -34
- package/dist/client/cluster.d.ts +0 -3
- package/dist/client/cluster.js +0 -32
- package/dist/client/database.d.ts +0 -16
- package/dist/client/database.js +0 -16
- package/dist/client/execute.d.ts +0 -33
- package/dist/client/execute.js +0 -38
- package/dist/client/javascript.d.ts +0 -23
- package/dist/client/javascript.js +0 -34
- package/dist/client/job_database.d.ts +0 -4
- package/dist/client/job_database.js +0 -4
- package/dist/client/job_execute.d.ts +0 -28
- package/dist/client/job_execute.js +0 -29
- package/dist/client/os.d.ts +0 -26
- package/dist/client/os.js +0 -32
- package/dist/client/resource.d.ts +0 -3
- package/dist/client/resource.js +0 -8
- package/dist/client/shell.d.ts +0 -16
- package/dist/client/shell.js +0 -21
- package/dist/computed.d.ts +0 -13
- package/dist/computed.js +32 -29
- package/dist/index.js +0 -4
- package/dist/interface/base.d.ts +0 -261
- package/dist/interface/base.js +0 -8
- package/dist/interface/bus.d.ts +0 -73
- package/dist/interface/enum.d.ts +0 -67
- package/dist/interface/enum.js +0 -74
- package/dist/interface/execute.d.ts +0 -46
- package/dist/interface/log.d.ts +0 -54
- package/dist/interface/plugin.d.ts +0 -192
- package/dist/interface/record.d.ts +0 -13
- package/dist/interface/server.d.ts +0 -20
- package/dist/interface/server.js +0 -8
- package/dist/interface/struct.d.ts +1 -140
- package/dist/interface/table.d.ts +0 -39
- package/dist/interface/ui.d.ts +0 -104
- package/dist/interface/ui.js +0 -8
- package/dist/interface.d.ts +0 -30
- package/dist/interface.js +18 -44
- package/dist/plugins/i18n.d.ts +0 -19
- package/dist/plugins/i18n.js +0 -24
- package/dist/script/console_manager.d.ts +0 -3
- package/dist/script/console_manager.js +0 -3
- package/dist/script/console_server_manager.d.ts +0 -3
- package/dist/script/console_server_manager.js +0 -3
- package/dist/script/execute/base.d.ts +2 -98
- package/dist/script/execute/base.js +0 -105
- package/dist/script/execute/feedback.d.ts +0 -34
- package/dist/script/execute/feedback.js +0 -46
- package/dist/script/execute/region_job.js +0 -6
- package/dist/script/execute/region_project.js +0 -17
- package/dist/script/execute/region_subtask.js +0 -5
- package/dist/script/execute/region_task.d.ts +5 -41
- package/dist/script/execute/region_task.js +0 -75
- package/dist/script/execute/runner.d.ts +0 -7
- package/dist/script/execute/runner.js +0 -15
- package/dist/script/execute/util_parser.d.ts +0 -41
- package/dist/script/execute/util_parser.js +1 -47
- package/dist/script/execute_manager.d.ts +0 -38
- package/dist/script/execute_manager.js +0 -54
- package/dist/script/socket_manager.d.ts +0 -79
- package/dist/script/socket_manager.js +0 -84
- package/dist/script/webhook_server_manager.js +1 -1
- package/dist/server/detail/console_handle.d.ts +0 -13
- package/dist/server/detail/console_handle.js +0 -14
- package/dist/server/detail/log_handle.d.ts +0 -5
- package/dist/server/detail/log_handle.js +0 -5
- package/dist/server/detail.d.ts +4 -32
- package/dist/server/detail.js +0 -43
- package/dist/server/io.d.ts +0 -21
- package/dist/server/io.js +0 -18
- package/dist/server/io2.d.ts +0 -19
- package/dist/server/io2.js +0 -54
- package/dist/server/module/account.d.ts +0 -6
- package/dist/server/module/account.js +0 -11
- package/dist/server/module/project.d.ts +1 -50
- package/dist/server/module/project.js +0 -49
- package/dist/server/plugin.d.ts +0 -51
- package/dist/server/plugin.js +0 -13
- package/dist/server/server.d.ts +0 -21
- package/dist/server/server.js +0 -10
- package/dist/server/server2.d.ts +0 -4
- package/dist/server/server2.js +0 -9
- package/dist/server.d.ts +0 -3
- package/dist/server.js +0 -3
- package/jest.config.js +11 -0
- package/package.json +3 -2
- package/src/client/client.ts +1 -1
- package/src/computed.ts +1 -5
- package/src/interface/struct.ts +1 -1
- package/src/script/webhook_server_manager.ts +1 -1
- package/test/call/print.ts +1 -1
- package/tsconfig.json +4 -4
- package/dist/util/port.d.ts +0 -1
- package/dist/util/port.js +0 -15
- package/jest.config.ts +0 -12
- package/src/util/port.ts +0 -15
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
2
|
import { Header, Messager, Messager_log } from "../interface";
|
|
3
3
|
import { Client } from './client';
|
|
4
|
-
/**
|
|
5
|
-
* The analysis worker. decode the message received from cluster server
|
|
6
|
-
*/
|
|
7
4
|
export declare class ClientAnalysis {
|
|
8
5
|
private messager;
|
|
9
6
|
private messager_log;
|
|
@@ -14,26 +11,12 @@ export declare class ClientAnalysis {
|
|
|
14
11
|
private resource_thread;
|
|
15
12
|
private resource_cache;
|
|
16
13
|
constructor(_messager: Messager, _messager_log: Messager_log, _client: Client);
|
|
17
|
-
/**
|
|
18
|
-
* Analysis the package
|
|
19
|
-
* @param h Package
|
|
20
|
-
* @param source Websocket instance
|
|
21
|
-
* @return
|
|
22
|
-
* * 0: Successfully execute command
|
|
23
|
-
* * 1: The header is undefined, cannot process
|
|
24
|
-
* * 2: Cannot find the header name match with function typeMap
|
|
25
|
-
*/
|
|
26
14
|
analysis: (h: Header | undefined, source: WebSocket) => 0 | 1 | 2;
|
|
27
15
|
private execute_job;
|
|
28
16
|
private release;
|
|
29
17
|
private set_database;
|
|
30
18
|
private set_libs;
|
|
31
19
|
private exec_checker;
|
|
32
|
-
/**
|
|
33
|
-
* Network delay request
|
|
34
|
-
* @param data Dummy value, should always be 0
|
|
35
|
-
* @param source The cluster server websocket instance
|
|
36
|
-
*/
|
|
37
20
|
private pong;
|
|
38
21
|
private plugin_info;
|
|
39
22
|
private get_releases;
|
package/dist/client/analysis.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// ========================
|
|
2
|
-
//
|
|
3
|
-
// Share Codebase
|
|
4
|
-
//
|
|
5
|
-
// ========================
|
|
6
1
|
import { exec, spawn } from 'child_process';
|
|
7
2
|
import { DATA_FOLDER } from "../interface";
|
|
8
3
|
import { Client } from './client';
|
|
@@ -11,9 +6,6 @@ import { ClientShell } from './shell';
|
|
|
11
6
|
import { createWriteStream, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
12
7
|
import * as path from 'path';
|
|
13
8
|
import * as os from 'os';
|
|
14
|
-
/**
|
|
15
|
-
* The analysis worker. decode the message received from cluster server
|
|
16
|
-
*/
|
|
17
9
|
export class ClientAnalysis {
|
|
18
10
|
messager;
|
|
19
11
|
messager_log;
|
|
@@ -30,15 +22,6 @@ export class ClientAnalysis {
|
|
|
30
22
|
this.shell = new ClientShell(_messager, _messager_log, this.client);
|
|
31
23
|
this.exec = [];
|
|
32
24
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Analysis the package
|
|
35
|
-
* @param h Package
|
|
36
|
-
* @param source Websocket instance
|
|
37
|
-
* @return
|
|
38
|
-
* * 0: Successfully execute command
|
|
39
|
-
* * 1: The header is undefined, cannot process
|
|
40
|
-
* * 2: Cannot find the header name match with function typeMap
|
|
41
|
-
*/
|
|
42
25
|
analysis = (h, source) => {
|
|
43
26
|
const typeMap = {
|
|
44
27
|
'execute_job': this.execute_job,
|
|
@@ -116,11 +99,6 @@ export class ClientAnalysis {
|
|
|
116
99
|
}
|
|
117
100
|
return r;
|
|
118
101
|
};
|
|
119
|
-
/**
|
|
120
|
-
* Network delay request
|
|
121
|
-
* @param data Dummy value, should always be 0
|
|
122
|
-
* @param source The cluster server websocket instance
|
|
123
|
-
*/
|
|
124
102
|
pong = (data, source) => {
|
|
125
103
|
const h = { name: 'pong', data: data };
|
|
126
104
|
source.send(JSON.stringify(h));
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
2
|
import { Messager, Messager_log, PluginNode } from '../interface';
|
|
3
|
-
/**
|
|
4
|
-
* **Compute Client**\
|
|
5
|
-
* The calculation node worker
|
|
6
|
-
*/
|
|
7
3
|
export declare class Client {
|
|
8
4
|
plugins: PluginNode;
|
|
9
5
|
private httpss;
|
|
@@ -13,27 +9,14 @@ export declare class Client {
|
|
|
13
9
|
private messager_log;
|
|
14
10
|
private analysis;
|
|
15
11
|
private updatehandle;
|
|
16
|
-
/**
|
|
17
|
-
* Get connected client count
|
|
18
|
-
*/
|
|
19
12
|
get count(): number;
|
|
20
|
-
/**
|
|
21
|
-
* Get connected client list instance
|
|
22
|
-
*/
|
|
23
13
|
get clients(): Array<WebSocket>;
|
|
24
14
|
constructor(_messager: Messager, _messager_log: Messager_log);
|
|
25
15
|
Dispose(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Start a websocket server, and waiting for cluster server to connect
|
|
28
|
-
*/
|
|
29
16
|
Init: () => Promise<void>;
|
|
30
17
|
Destroy: () => void;
|
|
31
18
|
Release: () => void;
|
|
32
19
|
savePlugin: () => void;
|
|
33
|
-
/**
|
|
34
|
-
* The node update function, It will do things below
|
|
35
|
-
* * Send system info to cluster server
|
|
36
|
-
*/
|
|
37
20
|
private update;
|
|
38
21
|
private loadPlugins;
|
|
39
22
|
private get_pem;
|
package/dist/client/client.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// ========================
|
|
2
|
-
//
|
|
3
|
-
// Share Codebase
|
|
4
|
-
//
|
|
5
|
-
// ========================
|
|
6
1
|
import * as path from 'path';
|
|
7
2
|
import { check } from 'tcp-port-used';
|
|
8
3
|
import * as ws from 'ws';
|
|
@@ -12,10 +7,6 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
|
12
7
|
import * as os from 'os';
|
|
13
8
|
import * as pem from 'pem';
|
|
14
9
|
import * as https from 'https';
|
|
15
|
-
/**
|
|
16
|
-
* **Compute Client**\
|
|
17
|
-
* The calculation node worker
|
|
18
|
-
*/
|
|
19
10
|
export class Client {
|
|
20
11
|
plugins = { plugins: [] };
|
|
21
12
|
httpss = undefined;
|
|
@@ -25,15 +16,9 @@ export class Client {
|
|
|
25
16
|
messager_log;
|
|
26
17
|
analysis;
|
|
27
18
|
updatehandle;
|
|
28
|
-
/**
|
|
29
|
-
* Get connected client count
|
|
30
|
-
*/
|
|
31
19
|
get count() {
|
|
32
20
|
return this.sources.length;
|
|
33
21
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Get connected client list instance
|
|
36
|
-
*/
|
|
37
22
|
get clients() {
|
|
38
23
|
return this.sources;
|
|
39
24
|
}
|
|
@@ -47,9 +32,6 @@ export class Client {
|
|
|
47
32
|
Dispose() {
|
|
48
33
|
clearInterval(this.updatehandle);
|
|
49
34
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Start a websocket server, and waiting for cluster server to connect
|
|
52
|
-
*/
|
|
53
35
|
Init = async () => {
|
|
54
36
|
let port_result = PORT;
|
|
55
37
|
let canbeuse = false;
|
|
@@ -68,7 +50,7 @@ export class Client {
|
|
|
68
50
|
res.end('HTTPS server is running');
|
|
69
51
|
});
|
|
70
52
|
this.httpss.addListener('upgrade', (req, res, head) => console.log('UPGRADE:', req.url));
|
|
71
|
-
this.client = new ws.
|
|
53
|
+
this.client = new ws.WebSocketServer({ server: this.httpss });
|
|
72
54
|
this.client.on('listening', () => {
|
|
73
55
|
this.messager_log('[Server] Listen PORT: ' + port_result.toString());
|
|
74
56
|
});
|
|
@@ -126,10 +108,6 @@ export class Client {
|
|
|
126
108
|
mkdirSync(f, { recursive: true });
|
|
127
109
|
writeFileSync(pluginPath, JSON.stringify(this.plugins, null, 4));
|
|
128
110
|
};
|
|
129
|
-
/**
|
|
130
|
-
* The node update function, It will do things below
|
|
131
|
-
* * Send system info to cluster server
|
|
132
|
-
*/
|
|
133
111
|
update = () => {
|
|
134
112
|
this.analysis.forEach(x => x.update(this));
|
|
135
113
|
};
|
|
@@ -165,17 +143,16 @@ export class Client {
|
|
|
165
143
|
});
|
|
166
144
|
};
|
|
167
145
|
static workerPath = (filename = "worker", extension = ".exe") => {
|
|
168
|
-
// @ts-ignore
|
|
169
146
|
const isExe = process.pkg?.entrypoint != undefined;
|
|
170
147
|
const exe = process.platform == 'win32' ? filename + extension : filename;
|
|
171
148
|
let workerExe = "";
|
|
172
149
|
let p = 0;
|
|
173
|
-
if (isExe && path.basename(process.execPath) == (process.platform ? "app.exe" : 'app')) {
|
|
150
|
+
if (isExe && path.basename(process.execPath) == (process.platform ? "app.exe" : 'app')) {
|
|
174
151
|
workerExe = path.join(process.execPath, "..", "bin", exe);
|
|
175
152
|
p = 1;
|
|
176
153
|
}
|
|
177
154
|
else if ((process.mainModule && process.mainModule.filename.indexOf('app.asar') !== -1) ||
|
|
178
|
-
process.argv.filter(a => a.indexOf('app.asar') !== -1).length > 0) {
|
|
155
|
+
process.argv.filter(a => a.indexOf('app.asar') !== -1).length > 0) {
|
|
179
156
|
workerExe = path.join("bin", exe);
|
|
180
157
|
p = 2;
|
|
181
158
|
}
|
|
@@ -183,29 +160,22 @@ export class Client {
|
|
|
183
160
|
workerExe = path.join(process.cwd(), "bin", exe);
|
|
184
161
|
p = 3;
|
|
185
162
|
}
|
|
186
|
-
else {
|
|
163
|
+
else {
|
|
187
164
|
workerExe = Client.isTypescript() ? path.join(__dirname, "bin", exe) : path.join(__dirname, "..", "bin", exe);
|
|
188
165
|
p = 4;
|
|
189
166
|
}
|
|
190
167
|
return workerExe;
|
|
191
168
|
};
|
|
192
169
|
static isTypescript = () => {
|
|
193
|
-
// if this file is typescript, we are running typescript :D
|
|
194
|
-
// this is the best check, but fails when actionhero is compiled to js though...
|
|
195
170
|
const extension = path.extname(__filename);
|
|
196
171
|
if (extension === ".ts") {
|
|
197
172
|
return true;
|
|
198
173
|
}
|
|
199
|
-
// are we running via a ts-node/ts-node-dev shim?
|
|
200
174
|
const lastArg = process.execArgv[process.execArgv.length - 1];
|
|
201
175
|
if (lastArg && path.parse(lastArg).name.indexOf("ts-node") > 0) {
|
|
202
176
|
return true;
|
|
203
177
|
}
|
|
204
178
|
try {
|
|
205
|
-
/**
|
|
206
|
-
* Are we running in typescript at the moment?
|
|
207
|
-
* see https://github.com/TypeStrong/ts-node/pull/858 for more details
|
|
208
|
-
*/
|
|
209
179
|
return process[Symbol.for("ts-node.register.instance")] ||
|
|
210
180
|
(process.env.NODE_ENV === "test" &&
|
|
211
181
|
process.env.ACTIONHERO_TEST_FILE_EXTENSION !== "js")
|
package/dist/client/cluster.d.ts
CHANGED
package/dist/client/cluster.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// ========================
|
|
2
|
-
//
|
|
3
|
-
// Share Codebase
|
|
4
|
-
//
|
|
5
|
-
// ========================
|
|
6
1
|
import { ResourceType } from '../interface';
|
|
7
2
|
import { ClientHTTP } from './http';
|
|
8
3
|
import { ClientJobExecute } from './job_execute';
|
|
@@ -18,11 +13,6 @@ process.stdin.on('data', (chunk) => {
|
|
|
18
13
|
setTimeout(process.exit(1), 1000);
|
|
19
14
|
}
|
|
20
15
|
});
|
|
21
|
-
/**
|
|
22
|
-
* The message handle for reply
|
|
23
|
-
* @param msg Message
|
|
24
|
-
* @param tag Message prefix
|
|
25
|
-
*/
|
|
26
16
|
const messager = (msg, tag) => {
|
|
27
17
|
const d = {
|
|
28
18
|
name: 'messager',
|
|
@@ -31,11 +21,6 @@ const messager = (msg, tag) => {
|
|
|
31
21
|
};
|
|
32
22
|
console.log(JSON.stringify(d));
|
|
33
23
|
};
|
|
34
|
-
/**
|
|
35
|
-
* The message handle for reply with print on screen ffeature
|
|
36
|
-
* @param msg Message
|
|
37
|
-
* @param tag Message prefix
|
|
38
|
-
*/
|
|
39
24
|
const messager_log = (msg, tag, meta) => {
|
|
40
25
|
const d = {
|
|
41
26
|
name: 'messager_log',
|
|
@@ -44,10 +29,6 @@ const messager_log = (msg, tag, meta) => {
|
|
|
44
29
|
};
|
|
45
30
|
console.log(JSON.stringify(d));
|
|
46
31
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Return the error message to main thread
|
|
49
|
-
* @param err Error instance
|
|
50
|
-
*/
|
|
51
32
|
const ERROR = (err) => {
|
|
52
33
|
const d = {
|
|
53
34
|
name: "error",
|
|
@@ -57,9 +38,6 @@ const ERROR = (err) => {
|
|
|
57
38
|
console.log(JSON.stringify(d));
|
|
58
39
|
process.exit(1);
|
|
59
40
|
};
|
|
60
|
-
/**
|
|
61
|
-
* Job execute task
|
|
62
|
-
*/
|
|
63
41
|
const execute_job = () => {
|
|
64
42
|
if (process.env.job == undefined || process.env.plugin == undefined) {
|
|
65
43
|
process.exit(1);
|
|
@@ -73,9 +51,6 @@ const execute_job = () => {
|
|
|
73
51
|
})
|
|
74
52
|
.catch(err => ERROR(err));
|
|
75
53
|
};
|
|
76
|
-
/**
|
|
77
|
-
* Query resource task
|
|
78
|
-
*/
|
|
79
54
|
const execute_resource = () => {
|
|
80
55
|
const r = new ClientResource();
|
|
81
56
|
messager("Resource query");
|
|
@@ -89,9 +64,6 @@ const execute_resource = () => {
|
|
|
89
64
|
console.log(JSON.stringify(h));
|
|
90
65
|
}).catch(err => ERROR(err));
|
|
91
66
|
};
|
|
92
|
-
/**
|
|
93
|
-
* Query http task
|
|
94
|
-
*/
|
|
95
67
|
const execute_http = () => {
|
|
96
68
|
const m = process.env.method || 'GET';
|
|
97
69
|
const u = process.env.url || '';
|
|
@@ -99,11 +71,7 @@ const execute_http = () => {
|
|
|
99
71
|
const r = new ClientHTTP(u, m, p);
|
|
100
72
|
r.RUN();
|
|
101
73
|
};
|
|
102
|
-
/**
|
|
103
|
-
* The entry point for the cluster thread.
|
|
104
|
-
*/
|
|
105
74
|
export function RUN() {
|
|
106
|
-
// The cluster currently spawn should execute a job
|
|
107
75
|
switch (process.env.type) {
|
|
108
76
|
case 'JOB':
|
|
109
77
|
execute_job();
|
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
import WebSocket from "ws";
|
|
2
2
|
import { Setter } from "../interface";
|
|
3
|
-
/**
|
|
4
|
-
* The database feedback helper\
|
|
5
|
-
* Update the main database container on the cluster server
|
|
6
|
-
*/
|
|
7
3
|
export declare class ClientDatabase {
|
|
8
4
|
private source;
|
|
9
5
|
constructor(_source: WebSocket | undefined);
|
|
10
|
-
/**
|
|
11
|
-
* Update database number on the cluster server
|
|
12
|
-
* @param data Target KeyValue
|
|
13
|
-
*/
|
|
14
6
|
feedbacknumber: (data: Setter) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Update database boolean on the cluster server
|
|
17
|
-
* @param data Target KeyValue
|
|
18
|
-
*/
|
|
19
7
|
feedbackboolean: (data: Setter) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Update database string on the cluster server
|
|
22
|
-
* @param data Target KeyValue
|
|
23
|
-
*/
|
|
24
8
|
feedbackstring: (data: Setter) => void;
|
|
25
9
|
feedbackobject: (data: Setter) => void;
|
|
26
10
|
feedbacklist: (data: Setter) => void;
|
package/dist/client/database.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The database feedback helper\
|
|
3
|
-
* Update the main database container on the cluster server
|
|
4
|
-
*/
|
|
5
1
|
export class ClientDatabase {
|
|
6
2
|
source;
|
|
7
3
|
constructor(_source) {
|
|
8
4
|
this.source = _source;
|
|
9
5
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Update database number on the cluster server
|
|
12
|
-
* @param data Target KeyValue
|
|
13
|
-
*/
|
|
14
6
|
feedbacknumber = (data) => {
|
|
15
7
|
this.feedback("feedback_number", data);
|
|
16
8
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Update database boolean on the cluster server
|
|
19
|
-
* @param data Target KeyValue
|
|
20
|
-
*/
|
|
21
9
|
feedbackboolean = (data) => {
|
|
22
10
|
this.feedback("feedback_boolean", data);
|
|
23
11
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Update database string on the cluster server
|
|
26
|
-
* @param data Target KeyValue
|
|
27
|
-
*/
|
|
28
12
|
feedbackstring = (data) => {
|
|
29
13
|
this.feedback("feedback_string", data);
|
|
30
14
|
};
|
package/dist/client/execute.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
2
|
import { Job, Libraries, Messager, Messager_log, Database, Setter } from "../interface";
|
|
3
3
|
import { Client } from "./client";
|
|
4
|
-
/**
|
|
5
|
-
* Execute worker, Execute the job container
|
|
6
|
-
*/
|
|
7
4
|
export declare class ClientExecute {
|
|
8
5
|
uuid: string;
|
|
9
6
|
private database;
|
|
@@ -15,43 +12,13 @@ export declare class ClientExecute {
|
|
|
15
12
|
private messager_log;
|
|
16
13
|
get count(): number;
|
|
17
14
|
constructor(_uuid: string, _messager: Messager, _messager_log: Messager_log, _client: Client);
|
|
18
|
-
/**
|
|
19
|
-
* The stop signal, It will trying to kill the process if currently running
|
|
20
|
-
*/
|
|
21
15
|
stop_job: () => void;
|
|
22
|
-
/**
|
|
23
|
-
* The entry function to execute the job container
|
|
24
|
-
* @param job Target job
|
|
25
|
-
*/
|
|
26
16
|
execute_job: (job: Job, source: WebSocket) => void;
|
|
27
17
|
private execute_job_worker;
|
|
28
18
|
private job_finish;
|
|
29
|
-
/**
|
|
30
|
-
* Update database, Called by cluster server
|
|
31
|
-
* @param data Target container
|
|
32
|
-
*/
|
|
33
19
|
set_database: (data: Database) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Update libraries, Called by cluster server
|
|
36
|
-
* @param data Target container
|
|
37
|
-
*/
|
|
38
20
|
set_libs: (data: Libraries) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Update database string, Called by cluster server
|
|
41
|
-
* @deprecated The method should not be used
|
|
42
|
-
* @param data Target keyvalue
|
|
43
|
-
*/
|
|
44
21
|
set_string: (data: Setter) => void;
|
|
45
|
-
/**
|
|
46
|
-
* Update database number, Called by cluster server
|
|
47
|
-
* @deprecated The method should not be used
|
|
48
|
-
* @param data Target keyvalue
|
|
49
|
-
*/
|
|
50
22
|
set_number: (data: Setter) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Update database boolean, Called by cluster server
|
|
53
|
-
* @deprecated The method should not be used
|
|
54
|
-
* @param data Target keyvalue
|
|
55
|
-
*/
|
|
56
23
|
set_boolean: (data: Setter) => void;
|
|
57
24
|
}
|
package/dist/client/execute.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
// ========================
|
|
2
|
-
//
|
|
3
|
-
// Share Codebase
|
|
4
|
-
//
|
|
5
|
-
// ========================
|
|
6
1
|
import { spawn } from 'child_process';
|
|
7
2
|
import { WebSocket } from 'ws';
|
|
8
3
|
import { DataType, JobCategory, JobType2Text, JobTypeText } from "../interface";
|
|
9
4
|
import { i18n } from "../plugins/i18n";
|
|
10
5
|
import { Client } from "./client";
|
|
11
6
|
import { ClientDatabase } from './database';
|
|
12
|
-
/**
|
|
13
|
-
* Execute worker, Execute the job container
|
|
14
|
-
*/
|
|
15
7
|
export class ClientExecute {
|
|
16
8
|
uuid;
|
|
17
9
|
database = undefined;
|
|
@@ -30,9 +22,6 @@ export class ClientExecute {
|
|
|
30
22
|
this.messager = _messager;
|
|
31
23
|
this.messager_log = _messager_log;
|
|
32
24
|
}
|
|
33
|
-
/**
|
|
34
|
-
* The stop signal, It will trying to kill the process if currently running
|
|
35
|
-
*/
|
|
36
25
|
stop_job = () => {
|
|
37
26
|
this.messager_log(`[Execute] Stop All: ${this.workers.length}`);
|
|
38
27
|
this.workers.forEach(x => {
|
|
@@ -42,10 +31,6 @@ export class ClientExecute {
|
|
|
42
31
|
x.stdin.end();
|
|
43
32
|
});
|
|
44
33
|
};
|
|
45
|
-
/**
|
|
46
|
-
* The entry function to execute the job container
|
|
47
|
-
* @param job Target job
|
|
48
|
-
*/
|
|
49
34
|
execute_job = (job, source) => {
|
|
50
35
|
this.messager_log(`[Execute] ${job.uuid} ${job.category == JobCategory.Execution ? i18n.global.t(JobTypeText[job.type]) : i18n.global.t(JobType2Text[job.type])}`, job.uuid, job.runtime_uuid);
|
|
51
36
|
this.tag = job.uuid;
|
|
@@ -150,25 +135,12 @@ export class ClientExecute {
|
|
|
150
135
|
}
|
|
151
136
|
this.tag = '';
|
|
152
137
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Update database, Called by cluster server
|
|
155
|
-
* @param data Target container
|
|
156
|
-
*/
|
|
157
138
|
set_database = (data) => {
|
|
158
139
|
this.database = data;
|
|
159
140
|
};
|
|
160
|
-
/**
|
|
161
|
-
* Update libraries, Called by cluster server
|
|
162
|
-
* @param data Target container
|
|
163
|
-
*/
|
|
164
141
|
set_libs = (data) => {
|
|
165
142
|
this.libraries = data;
|
|
166
143
|
};
|
|
167
|
-
/**
|
|
168
|
-
* Update database string, Called by cluster server
|
|
169
|
-
* @deprecated The method should not be used
|
|
170
|
-
* @param data Target keyvalue
|
|
171
|
-
*/
|
|
172
144
|
set_string = (data) => {
|
|
173
145
|
if (this.database == undefined)
|
|
174
146
|
return;
|
|
@@ -177,11 +149,6 @@ export class ClientExecute {
|
|
|
177
149
|
this.database.containers[index].value = data.value;
|
|
178
150
|
this.messager_log(`[Database string sync] ${data.key} = ${data.value}`);
|
|
179
151
|
};
|
|
180
|
-
/**
|
|
181
|
-
* Update database number, Called by cluster server
|
|
182
|
-
* @deprecated The method should not be used
|
|
183
|
-
* @param data Target keyvalue
|
|
184
|
-
*/
|
|
185
152
|
set_number = (data) => {
|
|
186
153
|
if (this.database == undefined)
|
|
187
154
|
return;
|
|
@@ -190,11 +157,6 @@ export class ClientExecute {
|
|
|
190
157
|
this.database.containers[index].value = data.value;
|
|
191
158
|
this.messager_log(`[Database number sync] ${data.key} = ${data.value}`);
|
|
192
159
|
};
|
|
193
|
-
/**
|
|
194
|
-
* Update database boolean, Called by cluster server
|
|
195
|
-
* @deprecated The method should not be used
|
|
196
|
-
* @param data Target keyvalue
|
|
197
|
-
*/
|
|
198
160
|
set_boolean = (data) => {
|
|
199
161
|
if (this.database == undefined)
|
|
200
162
|
return;
|
|
@@ -13,31 +13,8 @@ export declare class ClientJavascript {
|
|
|
13
13
|
message: any;
|
|
14
14
|
http: any;
|
|
15
15
|
constructor(_messager: Messager, _messager_log: Messager_log, _getjob: Getjob);
|
|
16
|
-
/**
|
|
17
|
-
* Before running the js scripts, We must init first.\
|
|
18
|
-
* ! Otherwise it won't work or throw error
|
|
19
|
-
* @param _messager Message habndle
|
|
20
|
-
* @param _messager_log Message habndle with print on screen feature
|
|
21
|
-
* @param _clientos OS worker
|
|
22
|
-
* @param _para Database worker
|
|
23
|
-
* @param _getlib library getter method
|
|
24
|
-
* @param _getpara Database getter method
|
|
25
|
-
* @param _getjob Job getter method
|
|
26
|
-
*/
|
|
27
16
|
static Init: (_messager: Messager, _messager_log: Messager, _clientos: ClientOS, _para: ClientJobDatabase, _getlib: Getlib, _getpara: Getpara, _getjob: Getjob) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Running js\
|
|
30
|
-
* With reference libraries\
|
|
31
|
-
* @param js js script text
|
|
32
|
-
* @param libs Libraries header names
|
|
33
|
-
* @returns Calcuate result
|
|
34
|
-
*/
|
|
35
17
|
JavascriptExecuteWithLib: (javascript: string, libs: Array<string>, log?: Messager) => Promise<any>;
|
|
36
|
-
/**
|
|
37
|
-
* Running js
|
|
38
|
-
* @param js js script text
|
|
39
|
-
* @returns Calcuate result
|
|
40
|
-
*/
|
|
41
18
|
JavascriptExecute: (javascript: string, log?: Messager) => Promise<any>;
|
|
42
19
|
private getJavascriptEnv;
|
|
43
20
|
private filename;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// ========================
|
|
2
|
-
//
|
|
3
|
-
// Share Codebase
|
|
4
|
-
//
|
|
5
|
-
// ========================
|
|
6
1
|
import * as vm from 'vm';
|
|
7
2
|
import { DATA_FOLDER, DataType, JavascriptLib } from '../interface';
|
|
8
3
|
import * as path from 'path';
|
|
@@ -41,7 +36,6 @@ let para = undefined;
|
|
|
41
36
|
let waiting = 0;
|
|
42
37
|
const tag = () => getjob?.()?.uuid ?? 'unknown';
|
|
43
38
|
const runtime = () => getjob?.()?.runtime_uuid ?? 'unknown';
|
|
44
|
-
//#region Global
|
|
45
39
|
function has(key, checker) {
|
|
46
40
|
const p = getpara?.() ?? undefined;
|
|
47
41
|
if (p == undefined)
|
|
@@ -200,7 +194,6 @@ function setselect(key, value) {
|
|
|
200
194
|
target.value = value;
|
|
201
195
|
para?.feedbackobject({ key: key, value: value });
|
|
202
196
|
}
|
|
203
|
-
//#endregion
|
|
204
197
|
export class ClientJavascript {
|
|
205
198
|
path;
|
|
206
199
|
os;
|
|
@@ -268,17 +261,6 @@ export class ClientJavascript {
|
|
|
268
261
|
patch: this.httpPatch,
|
|
269
262
|
};
|
|
270
263
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Before running the js scripts, We must init first.\
|
|
273
|
-
* ! Otherwise it won't work or throw error
|
|
274
|
-
* @param _messager Message habndle
|
|
275
|
-
* @param _messager_log Message habndle with print on screen feature
|
|
276
|
-
* @param _clientos OS worker
|
|
277
|
-
* @param _para Database worker
|
|
278
|
-
* @param _getlib library getter method
|
|
279
|
-
* @param _getpara Database getter method
|
|
280
|
-
* @param _getjob Job getter method
|
|
281
|
-
*/
|
|
282
264
|
static Init = (_messager, _messager_log, _clientos, _para, _getlib, _getpara, _getjob) => {
|
|
283
265
|
messager = _messager;
|
|
284
266
|
messager_log = _messager_log;
|
|
@@ -288,13 +270,6 @@ export class ClientJavascript {
|
|
|
288
270
|
getpara = _getpara;
|
|
289
271
|
getjob = _getjob;
|
|
290
272
|
};
|
|
291
|
-
/**
|
|
292
|
-
* Running js\
|
|
293
|
-
* With reference libraries\
|
|
294
|
-
* @param js js script text
|
|
295
|
-
* @param libs Libraries header names
|
|
296
|
-
* @returns Calcuate result
|
|
297
|
-
*/
|
|
298
273
|
JavascriptExecuteWithLib = (javascript, libs, log) => {
|
|
299
274
|
waiting = 0;
|
|
300
275
|
let context = this.getJavascriptEnv(JavascriptLib.ALL, log);
|
|
@@ -323,11 +298,6 @@ export class ClientJavascript {
|
|
|
323
298
|
}, 100);
|
|
324
299
|
});
|
|
325
300
|
};
|
|
326
|
-
/**
|
|
327
|
-
* Running js
|
|
328
|
-
* @param js js script text
|
|
329
|
-
* @returns Calcuate result
|
|
330
|
-
*/
|
|
331
301
|
JavascriptExecute = (javascript, log) => {
|
|
332
302
|
waiting = 0;
|
|
333
303
|
let context = this.getJavascriptEnv(JavascriptLib.OS | JavascriptLib.MESSAGE | JavascriptLib.HTTP | JavascriptLib.PATH, log);
|
|
@@ -490,16 +460,12 @@ export class ClientJavascript {
|
|
|
490
460
|
readfile(path) {
|
|
491
461
|
return clientos?.file_read({ path: path });
|
|
492
462
|
}
|
|
493
|
-
//#region Databases
|
|
494
463
|
async wait(time) {
|
|
495
464
|
return new Promise((resolve) => setTimeout(resolve, time * 1000));
|
|
496
465
|
}
|
|
497
466
|
async sleep(n) {
|
|
498
467
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n * 1000);
|
|
499
468
|
}
|
|
500
|
-
//#endregion
|
|
501
|
-
//#endregion
|
|
502
|
-
//#region Http
|
|
503
469
|
async httpGet(url, p) {
|
|
504
470
|
return this.httpGo('GET', url, p.toObject());
|
|
505
471
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Setter } from "../interface";
|
|
2
2
|
export declare class ClientJobDatabase {
|
|
3
|
-
/**
|
|
4
|
-
* Update database number on the cluster server
|
|
5
|
-
* @param data Target KeyValue
|
|
6
|
-
*/
|
|
7
3
|
feedbacknumber: (data: Setter) => void;
|
|
8
4
|
feedbackboolean: (data: Setter) => void;
|
|
9
5
|
feedbackstring: (data: Setter) => void;
|