verteilen-core 1.4.82 → 1.4.83
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 +117 -0
- package/dist/client/analysis.js +455 -0
- package/dist/client/analysis.js.map +1 -0
- package/dist/client/client.d.ts +63 -0
- package/dist/client/client.js +295 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/cluster.d.ts +4 -0
- package/dist/client/cluster.js +127 -0
- package/dist/client/cluster.js.map +1 -0
- package/dist/client/database.d.ts +29 -0
- package/dist/client/database.js +49 -0
- package/dist/client/database.js.map +1 -0
- package/dist/client/execute.d.ts +72 -0
- package/dist/client/execute.js +218 -0
- package/dist/client/execute.js.map +1 -0
- package/dist/client/http.d.ts +7 -0
- package/dist/client/http.js +38 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/javascript.d.ts +70 -0
- package/dist/client/javascript.js +593 -0
- package/dist/client/javascript.js.map +1 -0
- package/dist/client/job_database.d.ts +14 -0
- package/dist/client/job_database.js +41 -0
- package/dist/client/job_database.js.map +1 -0
- package/dist/client/job_execute.d.ts +51 -0
- package/dist/client/job_execute.js +192 -0
- package/dist/client/job_execute.js.map +1 -0
- package/dist/client/os.d.ts +62 -0
- package/dist/client/os.js +263 -0
- package/dist/client/os.js.map +1 -0
- package/dist/client/resource.d.ts +10 -0
- package/dist/client/resource.js +131 -0
- package/dist/client/resource.js.map +1 -0
- package/dist/client/shell.d.ts +32 -0
- package/dist/client/shell.js +149 -0
- package/dist/client/shell.js.map +1 -0
- package/dist/computed.d.ts +15 -0
- package/dist/computed.js +15 -0
- package/dist/computed.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Socket } from 'socket.io';
|
|
2
|
+
import { Messager, Messager_log } from "../interface";
|
|
3
|
+
import { Client } from './client';
|
|
4
|
+
/**
|
|
5
|
+
* The analysis worker. decode the message received from cluster server
|
|
6
|
+
*/
|
|
7
|
+
export declare class ClientAnalysis {
|
|
8
|
+
private messager;
|
|
9
|
+
private messager_log;
|
|
10
|
+
private client;
|
|
11
|
+
private socket;
|
|
12
|
+
private exec;
|
|
13
|
+
private shell;
|
|
14
|
+
private resource_wanter;
|
|
15
|
+
private resource_thread;
|
|
16
|
+
private resource_cache;
|
|
17
|
+
/**
|
|
18
|
+
* Create the worker
|
|
19
|
+
* @param _messager The log function at the lower level, Which does not send back to server
|
|
20
|
+
* @param _messager_log The log function at the higher level, Which does send back to server
|
|
21
|
+
* @param _client Client instance
|
|
22
|
+
*/
|
|
23
|
+
constructor(_client: Client, _socket: Socket, _messager: Messager, _messager_log: Messager_log);
|
|
24
|
+
/**
|
|
25
|
+
* Register socket io event
|
|
26
|
+
* @param h Package
|
|
27
|
+
* @param source Websocket instance
|
|
28
|
+
* @return
|
|
29
|
+
* * 0: Successfully execute command
|
|
30
|
+
* * 1: The header is undefined, cannot process
|
|
31
|
+
* * 2: Cannot find the header name match with function typeMap
|
|
32
|
+
*/
|
|
33
|
+
RegisterEvent: () => void;
|
|
34
|
+
private message;
|
|
35
|
+
/**
|
|
36
|
+
* Job execution, Pipe down to execution worker to execute the input job object
|
|
37
|
+
* @param job Job Object
|
|
38
|
+
* @param source Command source
|
|
39
|
+
* @param channel Job thread UUID channel
|
|
40
|
+
*/
|
|
41
|
+
private execute_job;
|
|
42
|
+
/**
|
|
43
|
+
* Release the job execution thread
|
|
44
|
+
* @param dummy Not important
|
|
45
|
+
* @param source Command source
|
|
46
|
+
* @param channel Job thread UUID channel
|
|
47
|
+
*/
|
|
48
|
+
private release;
|
|
49
|
+
/**
|
|
50
|
+
* Set buffer database
|
|
51
|
+
* @param data Database Object
|
|
52
|
+
* @param source Command source
|
|
53
|
+
* @param channel Job thread UUID channel
|
|
54
|
+
*/
|
|
55
|
+
private set_database;
|
|
56
|
+
/**
|
|
57
|
+
* Set buffer libraries
|
|
58
|
+
* @param data Libraries Object
|
|
59
|
+
* @param source Command source
|
|
60
|
+
* @param channel Job thread UUID channel
|
|
61
|
+
*/
|
|
62
|
+
private set_libs;
|
|
63
|
+
/**
|
|
64
|
+
* Get the execution channel by UUID
|
|
65
|
+
* @param uuid UUID
|
|
66
|
+
* @returns Execution worker instance
|
|
67
|
+
*/
|
|
68
|
+
private exec_checker;
|
|
69
|
+
/**
|
|
70
|
+
* Network delay request
|
|
71
|
+
* @param data Dummy value, should always be 0
|
|
72
|
+
* @param source The cluster server websocket instance
|
|
73
|
+
*/
|
|
74
|
+
private pong;
|
|
75
|
+
/**
|
|
76
|
+
* Feedback current plugin state to computed server
|
|
77
|
+
* @param dummy Not important
|
|
78
|
+
* @param source The cluster server websocket instance
|
|
79
|
+
*/
|
|
80
|
+
private plugin_info;
|
|
81
|
+
/**
|
|
82
|
+
* ? utility for plugin download\
|
|
83
|
+
* Get release info
|
|
84
|
+
* @param repo Repository name
|
|
85
|
+
* @param token If it's for private repo, You will need token here
|
|
86
|
+
* @returns The Json string info
|
|
87
|
+
*/
|
|
88
|
+
private get_releases;
|
|
89
|
+
/**
|
|
90
|
+
* ? utility for plugin download\
|
|
91
|
+
* Get the asset id from repo release info and filename, version\
|
|
92
|
+
* It's useful for getting a download link
|
|
93
|
+
* @param repo Repository
|
|
94
|
+
* @param token If it's for private repo, You will need token here
|
|
95
|
+
* @param version Target version
|
|
96
|
+
* @param filename Target filename
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
private filterout;
|
|
100
|
+
private write_plugin;
|
|
101
|
+
private finish_plugin;
|
|
102
|
+
/**
|
|
103
|
+
* Download the exe file from target plugin\
|
|
104
|
+
* And overwrite the plugin record
|
|
105
|
+
* @param plugin Target plugin
|
|
106
|
+
* @param source Command source
|
|
107
|
+
*/
|
|
108
|
+
private plugin_download;
|
|
109
|
+
private plugin_remove;
|
|
110
|
+
private resource_start;
|
|
111
|
+
private resource_end;
|
|
112
|
+
update: (client: Client) => void;
|
|
113
|
+
disconnect: (source: Socket) => void;
|
|
114
|
+
stop_all: () => void;
|
|
115
|
+
destroy: () => void;
|
|
116
|
+
private resource_require;
|
|
117
|
+
}
|
|
@@ -0,0 +1,455 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ClientAnalysis = void 0;
|
|
46
|
+
// ========================
|
|
47
|
+
//
|
|
48
|
+
// Share Codebase
|
|
49
|
+
//
|
|
50
|
+
// ========================
|
|
51
|
+
//
|
|
52
|
+
// ? Analysis the packets send from the computed server
|
|
53
|
+
//
|
|
54
|
+
const child_process_1 = require("child_process");
|
|
55
|
+
const interface_1 = require("../interface");
|
|
56
|
+
const client_1 = require("./client");
|
|
57
|
+
const execute_1 = require("./execute");
|
|
58
|
+
const shell_1 = require("./shell");
|
|
59
|
+
const fs_1 = require("fs");
|
|
60
|
+
const path = __importStar(require("path"));
|
|
61
|
+
const os = __importStar(require("os"));
|
|
62
|
+
/**
|
|
63
|
+
* The analysis worker. decode the message received from cluster server
|
|
64
|
+
*/
|
|
65
|
+
class ClientAnalysis {
|
|
66
|
+
/**
|
|
67
|
+
* Create the worker
|
|
68
|
+
* @param _messager The log function at the lower level, Which does not send back to server
|
|
69
|
+
* @param _messager_log The log function at the higher level, Which does send back to server
|
|
70
|
+
* @param _client Client instance
|
|
71
|
+
*/
|
|
72
|
+
constructor(_client, _socket, _messager, _messager_log) {
|
|
73
|
+
this.resource_wanter = [];
|
|
74
|
+
this.resource_thread = undefined;
|
|
75
|
+
this.resource_cache = undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Register socket io event
|
|
78
|
+
* @param h Package
|
|
79
|
+
* @param source Websocket instance
|
|
80
|
+
* @return
|
|
81
|
+
* * 0: Successfully execute command
|
|
82
|
+
* * 1: The header is undefined, cannot process
|
|
83
|
+
* * 2: Cannot find the header name match with function typeMap
|
|
84
|
+
*/
|
|
85
|
+
this.RegisterEvent = () => {
|
|
86
|
+
this.socket.on('message', this.message);
|
|
87
|
+
this.socket.on('execute_job', this.execute_job);
|
|
88
|
+
this.socket.on('release', this.release);
|
|
89
|
+
this.socket.on('stop_job', this.stop_all);
|
|
90
|
+
this.socket.on('set_database', this.set_database);
|
|
91
|
+
this.socket.on('set_libs', this.set_libs);
|
|
92
|
+
this.socket.on('shell_folder', this.shell.shell_folder);
|
|
93
|
+
this.socket.on('open_shell', (uuid) => this.shell.open_shell(uuid, this.socket));
|
|
94
|
+
this.socket.on('close_shell', this.shell.close_shell);
|
|
95
|
+
this.socket.on('enter_shell', this.shell.enter_shell);
|
|
96
|
+
this.socket.on('resource_start', this.resource_start);
|
|
97
|
+
this.socket.on('resource_end', this.resource_end);
|
|
98
|
+
this.socket.on('ping', this.pong);
|
|
99
|
+
this.socket.on('plugin_info', this.plugin_info);
|
|
100
|
+
this.socket.on('plugin_download', this.plugin_download);
|
|
101
|
+
this.socket.on('plugin_remove', this.plugin_remove);
|
|
102
|
+
};
|
|
103
|
+
this.message = (msg) => {
|
|
104
|
+
this.messager_log(`[Client Analysis] ${msg}`);
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Job execution, Pipe down to execution worker to execute the input job object
|
|
108
|
+
* @param job Job Object
|
|
109
|
+
* @param source Command source
|
|
110
|
+
* @param channel Job thread UUID channel
|
|
111
|
+
*/
|
|
112
|
+
this.execute_job = (job, channel) => {
|
|
113
|
+
if (channel == undefined)
|
|
114
|
+
return;
|
|
115
|
+
const target = this.exec_checker(channel);
|
|
116
|
+
target.execute_job(job, this.socket);
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Release the job execution thread
|
|
120
|
+
* @param dummy Not important
|
|
121
|
+
* @param source Command source
|
|
122
|
+
* @param channel Job thread UUID channel
|
|
123
|
+
*/
|
|
124
|
+
this.release = (channel) => {
|
|
125
|
+
if (channel == undefined)
|
|
126
|
+
return;
|
|
127
|
+
const index = this.exec.findIndex(x => x.uuid == channel);
|
|
128
|
+
if (index == -1)
|
|
129
|
+
return;
|
|
130
|
+
this.exec.splice(index, 1);
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Set buffer database
|
|
134
|
+
* @param data Database Object
|
|
135
|
+
* @param source Command source
|
|
136
|
+
* @param channel Job thread UUID channel
|
|
137
|
+
*/
|
|
138
|
+
this.set_database = (data, channel) => {
|
|
139
|
+
if (channel == undefined)
|
|
140
|
+
return;
|
|
141
|
+
const target = this.exec_checker(channel);
|
|
142
|
+
target.set_database(data);
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Set buffer libraries
|
|
146
|
+
* @param data Libraries Object
|
|
147
|
+
* @param source Command source
|
|
148
|
+
* @param channel Job thread UUID channel
|
|
149
|
+
*/
|
|
150
|
+
this.set_libs = (data, channel) => {
|
|
151
|
+
if (channel == undefined)
|
|
152
|
+
return;
|
|
153
|
+
const target = this.exec_checker(channel);
|
|
154
|
+
target.set_libs(data);
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Get the execution channel by UUID
|
|
158
|
+
* @param uuid UUID
|
|
159
|
+
* @returns Execution worker instance
|
|
160
|
+
*/
|
|
161
|
+
this.exec_checker = (uuid) => {
|
|
162
|
+
let r = undefined;
|
|
163
|
+
const index = this.exec.findIndex(x => x.uuid == uuid);
|
|
164
|
+
if (index == -1) {
|
|
165
|
+
r = new execute_1.ClientExecute(uuid, this.messager, this.messager_log, this.client);
|
|
166
|
+
this.exec.push(r);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
r = this.exec[index];
|
|
170
|
+
}
|
|
171
|
+
return r;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Network delay request
|
|
175
|
+
* @param data Dummy value, should always be 0
|
|
176
|
+
* @param source The cluster server websocket instance
|
|
177
|
+
*/
|
|
178
|
+
this.pong = (id) => {
|
|
179
|
+
this.socket.emit('pong', id);
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Feedback current plugin state to computed server
|
|
183
|
+
* @param dummy Not important
|
|
184
|
+
* @param source The cluster server websocket instance
|
|
185
|
+
*/
|
|
186
|
+
this.plugin_info = () => {
|
|
187
|
+
const pat = path.join(os.homedir(), interface_1.DATA_FOLDER, "node_plugin", "plugin.json");
|
|
188
|
+
if ((0, fs_1.existsSync)(pat)) {
|
|
189
|
+
const p = JSON.parse((0, fs_1.readFileSync)(pat).toString());
|
|
190
|
+
const h = { name: 'plugin_info_reply', data: p.plugins };
|
|
191
|
+
this.socket.send(JSON.stringify(h));
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const p = { plugins: [] };
|
|
195
|
+
const h = { name: 'plugin_info_reply', data: p.plugins };
|
|
196
|
+
(0, fs_1.writeFileSync)(pat, JSON.stringify(p));
|
|
197
|
+
this.socket.send(JSON.stringify(h));
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* ? utility for plugin download\
|
|
202
|
+
* Get release info
|
|
203
|
+
* @param repo Repository name
|
|
204
|
+
* @param token If it's for private repo, You will need token here
|
|
205
|
+
* @returns The Json string info
|
|
206
|
+
*/
|
|
207
|
+
this.get_releases = (repo, token) => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const qu = yield fetch(`https://api.github.com/repos/${repo}/releases`, {
|
|
209
|
+
headers: {
|
|
210
|
+
Authorization: token ? `token ${token}` : '',
|
|
211
|
+
Accept: "application/vnd.github.v3.raw",
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
return qu.text();
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* ? utility for plugin download\
|
|
218
|
+
* Get the asset id from repo release info and filename, version\
|
|
219
|
+
* It's useful for getting a download link
|
|
220
|
+
* @param repo Repository
|
|
221
|
+
* @param token If it's for private repo, You will need token here
|
|
222
|
+
* @param version Target version
|
|
223
|
+
* @param filename Target filename
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
this.filterout = (repo, token, version, filename) => __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
const text = yield this.get_releases(repo, token);
|
|
228
|
+
const json = JSON.parse(text);
|
|
229
|
+
const v = json.find(x => x.tag_name == version);
|
|
230
|
+
if (!v)
|
|
231
|
+
return;
|
|
232
|
+
const f = v.assets.find(x => x.name == filename);
|
|
233
|
+
if (!f)
|
|
234
|
+
return;
|
|
235
|
+
return f.id;
|
|
236
|
+
});
|
|
237
|
+
this.write_plugin = (t, plugin) => {
|
|
238
|
+
const list = this.client.plugins.plugins;
|
|
239
|
+
const index = list.findIndex(x => x.name == plugin.name);
|
|
240
|
+
plugin.token = t ? [t] : [];
|
|
241
|
+
plugin.progress = 0;
|
|
242
|
+
if (index == -1) {
|
|
243
|
+
list.push(plugin);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
list[index] = plugin;
|
|
247
|
+
}
|
|
248
|
+
this.client.savePlugin();
|
|
249
|
+
this.plugin_info();
|
|
250
|
+
};
|
|
251
|
+
this.finish_plugin = (plugin) => {
|
|
252
|
+
const list = this.client.plugins.plugins;
|
|
253
|
+
const index = list.findIndex(x => x.name == plugin.name);
|
|
254
|
+
plugin.progress = 1;
|
|
255
|
+
if (index == -1) {
|
|
256
|
+
list.push(plugin);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
list[index] = plugin;
|
|
260
|
+
}
|
|
261
|
+
this.client.savePlugin();
|
|
262
|
+
this.plugin_info();
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Download the exe file from target plugin\
|
|
266
|
+
* And overwrite the plugin record
|
|
267
|
+
* @param plugin Target plugin
|
|
268
|
+
* @param source Command source
|
|
269
|
+
*/
|
|
270
|
+
this.plugin_download = (plugin) => __awaiter(this, void 0, void 0, function* () {
|
|
271
|
+
const target = plugin.contents.find(x => x.arch == process.arch && x.platform == process.platform);
|
|
272
|
+
if (target == undefined) {
|
|
273
|
+
this.messager_log(`[Plugin] Cannot find target plugin for ${plugin.name} on ${process.platform} ${process.arch}`);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const links = target.url.split('/');
|
|
277
|
+
const filename = links[links.length - 1];
|
|
278
|
+
const version = links[links.length - 2];
|
|
279
|
+
const REPO = `${links[3]}/${links[4]}`;
|
|
280
|
+
const dir = path.join(os.homedir(), interface_1.DATA_FOLDER, "node_plugin", plugin.name);
|
|
281
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
282
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
283
|
+
let req = {};
|
|
284
|
+
const tokens = [undefined, ...plugin.token];
|
|
285
|
+
const fileStream = (0, fs_1.createWriteStream)(path.join(dir, target.filename), { flags: 'a' });
|
|
286
|
+
let pass = false;
|
|
287
|
+
for (let t of tokens) {
|
|
288
|
+
if (pass)
|
|
289
|
+
break;
|
|
290
|
+
try {
|
|
291
|
+
const id = yield this.filterout(REPO, t, version, filename);
|
|
292
|
+
req = {
|
|
293
|
+
method: 'GET',
|
|
294
|
+
credentials: 'include',
|
|
295
|
+
headers: {
|
|
296
|
+
Authorization: t ? `token ${t}` : '',
|
|
297
|
+
Accept: "application/octet-stream"
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const url = `https://api.github.com/repos/${REPO}/releases/assets/${id}`;
|
|
301
|
+
fetch(url, req).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
if (!res.ok) {
|
|
303
|
+
throw new Error(`Failed to download file: ${res.status} ${res.statusText}`);
|
|
304
|
+
}
|
|
305
|
+
this.write_plugin(t, plugin);
|
|
306
|
+
return res.blob();
|
|
307
|
+
})).then(blob => {
|
|
308
|
+
return blob.stream().getReader().read();
|
|
309
|
+
})
|
|
310
|
+
.then(reader => {
|
|
311
|
+
if (!reader.done) {
|
|
312
|
+
fileStream.write(Buffer.from(reader.value));
|
|
313
|
+
}
|
|
314
|
+
}).finally(() => {
|
|
315
|
+
this.messager_log(`[Plugin] Downloaded ${plugin.name} successfully`);
|
|
316
|
+
fileStream.end();
|
|
317
|
+
if (process.platform == 'linux') {
|
|
318
|
+
(0, child_process_1.exec)(`chmod +x ${path.join(dir, target.filename)}`, (err) => {
|
|
319
|
+
if (err)
|
|
320
|
+
this.messager_log(`[Plugin] Permission failed ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
321
|
+
else
|
|
322
|
+
this.messager_log(`[Plugin] Apply Execute Permission Successfully`);
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
this.finish_plugin(plugin);
|
|
326
|
+
pass = true;
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
this.messager_log(`[Plugin] Download failed for ${plugin.name}: ${err.message}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
this.plugin_remove = (plugin) => {
|
|
335
|
+
this.client.plugins.plugins = this.client.plugins.plugins.filter(x => x.name != plugin.name);
|
|
336
|
+
this.client.savePlugin();
|
|
337
|
+
const dir = path.join(os.homedir(), interface_1.DATA_FOLDER, "node_plugin");
|
|
338
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
339
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
340
|
+
if ((0, fs_1.existsSync)(path.join(dir, plugin.name))) {
|
|
341
|
+
(0, fs_1.rmSync)(path.join(dir, plugin.name), { recursive: true });
|
|
342
|
+
}
|
|
343
|
+
this.plugin_info();
|
|
344
|
+
};
|
|
345
|
+
this.resource_start = (data, source) => {
|
|
346
|
+
this.resource_wanter.push(source);
|
|
347
|
+
this.messager_log(`Register resource_wanter!, count: ${this.resource_wanter.length}`);
|
|
348
|
+
if (this.resource_cache != undefined)
|
|
349
|
+
source.send(JSON.stringify(this.resource_cache));
|
|
350
|
+
};
|
|
351
|
+
this.resource_end = (data, source) => {
|
|
352
|
+
const index = this.resource_wanter.findIndex(x => x == source);
|
|
353
|
+
if (index != -1) {
|
|
354
|
+
this.resource_wanter.splice(index, 1);
|
|
355
|
+
this.messager_log(`UnRegister resource_wanter!, count: ${this.resource_wanter.length}`);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
this.update = (client) => {
|
|
359
|
+
this.resource_require();
|
|
360
|
+
if (this.resource_cache != undefined) {
|
|
361
|
+
this.resource_wanter.forEach(x => x.send(JSON.stringify(this.resource_cache)));
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
this.disconnect = (source) => {
|
|
365
|
+
this.shell.disconnect2(source);
|
|
366
|
+
this.exec.forEach(x => x.stop_job());
|
|
367
|
+
};
|
|
368
|
+
this.stop_all = () => {
|
|
369
|
+
this.exec.forEach(x => x.stop_job());
|
|
370
|
+
};
|
|
371
|
+
this.destroy = () => {
|
|
372
|
+
if (this.resource_thread != undefined)
|
|
373
|
+
this.resource_thread.kill();
|
|
374
|
+
};
|
|
375
|
+
this.resource_require = () => {
|
|
376
|
+
var _a, _b, _c, _d;
|
|
377
|
+
if (this.resource_thread != undefined)
|
|
378
|
+
return;
|
|
379
|
+
const shouldRun = this.resource_thread == undefined && (this.resource_cache == undefined || this.resource_wanter.length > 0);
|
|
380
|
+
if (!shouldRun)
|
|
381
|
+
return;
|
|
382
|
+
this.resource_thread = (0, child_process_1.spawn)(client_1.Client.workerPath(), [], {
|
|
383
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
384
|
+
shell: true,
|
|
385
|
+
windowsHide: true,
|
|
386
|
+
env: Object.assign(Object.assign({}, process.env), { type: "RESOURCE", cache: this.resource_cache == undefined ? undefined : JSON.stringify(this.resource_cache.data) })
|
|
387
|
+
});
|
|
388
|
+
let k = "";
|
|
389
|
+
const workerFeedbackExec = (str) => {
|
|
390
|
+
try {
|
|
391
|
+
const msg = JSON.parse(str);
|
|
392
|
+
if (msg.name == 'messager') {
|
|
393
|
+
this.messager(msg.data, "RESOURCE");
|
|
394
|
+
}
|
|
395
|
+
else if (msg.name == 'messager_log') {
|
|
396
|
+
this.messager_log(msg.data, "RESOURCE");
|
|
397
|
+
}
|
|
398
|
+
else if (msg.name == 'resource') {
|
|
399
|
+
const h = {
|
|
400
|
+
name: 'system_info',
|
|
401
|
+
data: msg.data
|
|
402
|
+
};
|
|
403
|
+
this.resource_cache = h;
|
|
404
|
+
this.resource_wanter.forEach(x => x.send(JSON.stringify(h)));
|
|
405
|
+
}
|
|
406
|
+
else if (msg.name == 'error') {
|
|
407
|
+
if (msg.data instanceof String)
|
|
408
|
+
this.messager_log(msg.data.toString(), "RESOURCE");
|
|
409
|
+
else
|
|
410
|
+
this.messager_log(JSON.stringify(msg.data), "RESOURCE");
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
catch (err) {
|
|
414
|
+
console.log("str: " + str);
|
|
415
|
+
console.log(err.name + "\n" + err.message);
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
const workerFeedback = (str) => {
|
|
419
|
+
for (let i = 0; i < str.length; i++) {
|
|
420
|
+
if (str[i] != '\n')
|
|
421
|
+
k += str[i];
|
|
422
|
+
else {
|
|
423
|
+
workerFeedbackExec(k);
|
|
424
|
+
k = '';
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
this.resource_thread.on('error', (err) => {
|
|
429
|
+
this.messager_log(`[Worker Error] ${err}`);
|
|
430
|
+
});
|
|
431
|
+
this.resource_thread.on('exit', (code, signal) => {
|
|
432
|
+
this.resource_thread = undefined;
|
|
433
|
+
});
|
|
434
|
+
this.resource_thread.on('message', (message, sendHandle) => {
|
|
435
|
+
workerFeedback(message.toString());
|
|
436
|
+
});
|
|
437
|
+
(_a = this.resource_thread.stdout) === null || _a === void 0 ? void 0 : _a.setEncoding('utf8');
|
|
438
|
+
(_b = this.resource_thread.stdout) === null || _b === void 0 ? void 0 : _b.on('data', (chunk) => {
|
|
439
|
+
workerFeedback(chunk.toString());
|
|
440
|
+
});
|
|
441
|
+
(_c = this.resource_thread.stderr) === null || _c === void 0 ? void 0 : _c.setEncoding('utf8');
|
|
442
|
+
(_d = this.resource_thread.stderr) === null || _d === void 0 ? void 0 : _d.on('data', (chunk) => {
|
|
443
|
+
workerFeedback(chunk.toString());
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
this.client = _client;
|
|
447
|
+
this.socket = _socket;
|
|
448
|
+
this.messager = _messager;
|
|
449
|
+
this.messager_log = _messager_log;
|
|
450
|
+
this.shell = new shell_1.ClientShell(_messager, _messager_log, this.client);
|
|
451
|
+
this.exec = [];
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
exports.ClientAnalysis = ClientAnalysis;
|
|
455
|
+
//# sourceMappingURL=analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../src/client/analysis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA2B;AAC3B,6BAA6B;AAC7B,2BAA2B;AAC3B,6BAA6B;AAC7B,2BAA2B;AAC3B,EAAE;AACF,wDAAwD;AACxD,EAAE;AACF,iDAAyE;AAEzE,4CAA0I;AAC1I,qCAAkC;AAClC,uCAA0C;AAC1C,mCAAsC;AACtC,2BAAmG;AACnG,2CAA6B;AAC7B,uCAAyB;AAEzB;;GAEG;AACH,MAAa,cAAc;IAYvB;;;;;OAKG;IACH,YAAY,OAAc,EAAE,OAAc,EAAE,SAAkB,EAAE,aAA0B;QAXlF,oBAAe,GAAoB,EAAE,CAAA;QACrC,oBAAe,GAA4B,SAAS,CAAA;QAEpD,mBAAc,GAAsB,SAAS,CAAA;QAiBrD;;;;;;;;WAQG;QACH,kBAAa,GAAG,GAAG,EAAE;YACjB,IAAI,CAAC,MA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,MAAM,GAAG,OAAO,CAAA;QACrB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,aAAa,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAW,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;IAClB,CAAC;CA2XJ;AApZD,wCAoZC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Socket } from 'socket.io';
|
|
2
|
+
import { Messager, Messager_log, PluginNode } from '../interface';
|
|
3
|
+
/**
|
|
4
|
+
* **Compute Client**\
|
|
5
|
+
* The calculation node worker
|
|
6
|
+
*/
|
|
7
|
+
export declare class Client {
|
|
8
|
+
/**
|
|
9
|
+
* **Plugin Record**\
|
|
10
|
+
* Use {@link loadPlugins} to load the plugin from disk
|
|
11
|
+
*/
|
|
12
|
+
plugins: PluginNode;
|
|
13
|
+
private httpss;
|
|
14
|
+
private client;
|
|
15
|
+
private sources;
|
|
16
|
+
private messager;
|
|
17
|
+
private messager_log;
|
|
18
|
+
private analysis;
|
|
19
|
+
private updatehandle;
|
|
20
|
+
/**
|
|
21
|
+
* Get connected client count
|
|
22
|
+
*/
|
|
23
|
+
get count(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Get connected client list instance
|
|
26
|
+
*/
|
|
27
|
+
get clients(): Array<Socket>;
|
|
28
|
+
constructor(_messager: Messager, _messager_log: Messager_log);
|
|
29
|
+
Dispose(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Start a websocket server, and waiting for cluster server to connect
|
|
32
|
+
*/
|
|
33
|
+
Init: () => Promise<void>;
|
|
34
|
+
Destroy: () => void;
|
|
35
|
+
Release: () => void;
|
|
36
|
+
savePlugin: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* The node update function, It will do things below
|
|
39
|
+
* * Send system info to cluster server
|
|
40
|
+
*/
|
|
41
|
+
private update;
|
|
42
|
+
/**
|
|
43
|
+
* Load plugin info from disk
|
|
44
|
+
* @param init Whether or not delete the downloading one
|
|
45
|
+
*/
|
|
46
|
+
private loadPlugins;
|
|
47
|
+
/**
|
|
48
|
+
* Get https key and cert from disk
|
|
49
|
+
* @returns [Key, Cert]
|
|
50
|
+
*/
|
|
51
|
+
private get_pem;
|
|
52
|
+
/**
|
|
53
|
+
* Get worker exe file path, but it could use in different file as well
|
|
54
|
+
* @param filename Worker file without extension
|
|
55
|
+
* @param extension file extension
|
|
56
|
+
* @returns The target file path
|
|
57
|
+
*/
|
|
58
|
+
static workerPath: (filename?: string, extension?: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Check If we're currently in the typescript environment
|
|
61
|
+
*/
|
|
62
|
+
static isTypescript: () => boolean;
|
|
63
|
+
}
|