@andersbakken/fisk 3.5.6 → 3.6.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/VM_runtime.js +4040 -0
- package/dist/VM_runtime.js.map +1 -0
- package/dist/fisk-builder.js +55239 -0
- package/dist/fisk-builder.js.map +1 -0
- package/dist/fisk-daemon.js +4223 -0
- package/dist/fisk-daemon.js.map +1 -0
- package/dist/fisk-scheduler.js +53883 -0
- package/dist/fisk-scheduler.js.map +1 -0
- package/package.json +68 -34
- package/builder/VM.js +0 -156
- package/builder/VM_runtime.js +0 -171
- package/builder/client.js +0 -181
- package/builder/compile.js +0 -269
- package/builder/fisk-builder.js +0 -899
- package/builder/load.js +0 -85
- package/builder/objectcache.js +0 -301
- package/builder/quit-on-error.js +0 -9
- package/builder/server.js +0 -214
- package/common/index.js +0 -45
- package/daemon/client.js +0 -100
- package/daemon/clientbuffer.js +0 -73
- package/daemon/compile.js +0 -140
- package/daemon/constants.js +0 -13
- package/daemon/fisk-daemon.js +0 -166
- package/daemon/server.js +0 -81
- package/daemon/slots.js +0 -69
- package/monitor/fisk-monitor.js +0 -767
- package/proxy/fisk-proxy.js +0 -150
- package/scheduler/database.js +0 -144
- package/scheduler/environments.js +0 -386
- package/scheduler/fisk-scheduler.js +0 -1411
- package/scheduler/objectcachemanager.js +0 -306
- package/scheduler/peak.js +0 -112
- package/scheduler/public/index.html +0 -37
- package/scheduler/server.js +0 -431
- package/scheduler/usertester.js +0 -60
package/scheduler/server.js
DELETED
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
const EventEmitter = require("events");
|
|
2
|
-
const WebSocket = require("ws");
|
|
3
|
-
const Url = require("url");
|
|
4
|
-
const http = require("http");
|
|
5
|
-
const express = require("express");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const crypto = require("crypto");
|
|
8
|
-
|
|
9
|
-
class Client extends EventEmitter {
|
|
10
|
-
constructor(object) {
|
|
11
|
-
super();
|
|
12
|
-
this.created = new Date();
|
|
13
|
-
Object.assign(this, object);
|
|
14
|
-
this.pingSent = undefined;
|
|
15
|
-
this.ws.on("pong", () => {
|
|
16
|
-
// console.log("got pong", this.name);
|
|
17
|
-
this.pingSent = undefined;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
send(type, msg) {
|
|
22
|
-
try {
|
|
23
|
-
if (msg === undefined) {
|
|
24
|
-
if (type instanceof Buffer) {
|
|
25
|
-
this.ws.send(type);
|
|
26
|
-
} else {
|
|
27
|
-
this.ws.send(JSON.stringify(type));
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
let tosend;
|
|
31
|
-
if (typeof msg === "object") {
|
|
32
|
-
tosend = msg;
|
|
33
|
-
tosend.type = type;
|
|
34
|
-
} else {
|
|
35
|
-
tosend = { type: type, message: msg };
|
|
36
|
-
}
|
|
37
|
-
this.ws.send(JSON.stringify(tosend));
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
ping() {
|
|
45
|
-
if (this.option && this.pingSent) {
|
|
46
|
-
const max = this.option.int("max-pong-interval", 60000);
|
|
47
|
-
console.log("checking ping", max, Date.now() - max, this.pingSent);
|
|
48
|
-
if (Date.now() - max > this.pingSent) {
|
|
49
|
-
this.ws.close();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
this.ws.ping();
|
|
54
|
-
this.pingSent = Date.now();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
error(message) {
|
|
58
|
-
try {
|
|
59
|
-
this.ws.send(`{"error": "${message}"}`);
|
|
60
|
-
this.ws.close();
|
|
61
|
-
this.emit("error", message);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
close() {
|
|
67
|
-
this.ws.close();
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
Client.Type = {
|
|
72
|
-
Builder: 0,
|
|
73
|
-
Compile: 1,
|
|
74
|
-
UploadEnvironment: 2,
|
|
75
|
-
Monitor: 3,
|
|
76
|
-
ClientVerify: 4
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
class Server extends EventEmitter {
|
|
80
|
-
constructor(option, configVersion) {
|
|
81
|
-
super();
|
|
82
|
-
this.option = option;
|
|
83
|
-
this.configVersion = configVersion;
|
|
84
|
-
this.id = 0;
|
|
85
|
-
this.nonces = {};
|
|
86
|
-
this.objectCache = undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
listen() {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
this.app = express();
|
|
92
|
-
this.emit("listen", this.app);
|
|
93
|
-
|
|
94
|
-
let ui = this.option("ui");
|
|
95
|
-
if (ui) {
|
|
96
|
-
this.app.all("/*", function(req, res, next) {
|
|
97
|
-
res.redirect(ui);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
this.server = http.createServer(this.app);
|
|
102
|
-
this.ws = new WebSocket.Server({ noServer: true });
|
|
103
|
-
const port = this.option.int("port", 8097);
|
|
104
|
-
let defaultBacklog = 128;
|
|
105
|
-
try {
|
|
106
|
-
defaultBacklog = parseInt(fs.readFileSync("/proc/sys/net/core/somaxconn", "utf8")) || 128;
|
|
107
|
-
} catch (err) {
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let backlog = this.option.int("backlog", defaultBacklog);
|
|
111
|
-
this.server.listen({ port, backlog, host: "0.0.0.0" });
|
|
112
|
-
|
|
113
|
-
this.server.on("upgrade", (req, socket, head) => {
|
|
114
|
-
this.ws.handleUpgrade(req, socket, head, (ws) => {
|
|
115
|
-
this._handleConnection(ws, req);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
this.ws.on("headers", (headers, request) => {
|
|
120
|
-
const url = Url.parse(request.url);
|
|
121
|
-
headers.push("x-fisk-object-cache: " + (this.objectCache ? "true" : "false"));
|
|
122
|
-
if (url.pathname == "/monitor") {
|
|
123
|
-
const nonce = crypto.randomBytes(256).toString("base64");
|
|
124
|
-
headers.push(`x-fisk-nonce: ${nonce}`);
|
|
125
|
-
request.nonce = nonce;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
this.server.on("error", error => {
|
|
130
|
-
if (error.code == "EADDRINUSE") {
|
|
131
|
-
console.log(`Port ${port} is in use...`);
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
this.server.listen({ port, backlog, host: "0.0.0.0" });
|
|
134
|
-
}, 1000);
|
|
135
|
-
} else {
|
|
136
|
-
console.error("Got server error", error.toString());
|
|
137
|
-
this.emit("error", error);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
this.server.once("listening", () => {
|
|
141
|
-
console.log("listening on", port);
|
|
142
|
-
resolve();
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
get express() { return this.app; }
|
|
148
|
-
|
|
149
|
-
_handleCompile(req, client) {
|
|
150
|
-
// look at headers
|
|
151
|
-
if (!("x-fisk-environments" in req.headers)) {
|
|
152
|
-
client.error("No x-fisk-environments header");
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const configVersion = req.headers["x-fisk-config-version"];
|
|
157
|
-
if (configVersion != this.configVersion) {
|
|
158
|
-
client.error(`Bad config version, expected ${this.configVersion}, got ${configVersion}`);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const compileEnvironment = req.headers["x-fisk-environments"];
|
|
162
|
-
|
|
163
|
-
let data = {
|
|
164
|
-
environment: compileEnvironment,
|
|
165
|
-
sourceFile: req.headers["x-fisk-sourcefile"],
|
|
166
|
-
sha1: req.headers["x-fisk-sha1"]
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
if (data.sha1 && data.sha1.length != 40) {
|
|
170
|
-
client.error(`Bad sha1 sum: ${data.sha1}`);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const npmVersion = req.headers["x-fisk-npm-version"];
|
|
174
|
-
if (npmVersion)
|
|
175
|
-
data.npmVersion = npmVersion;
|
|
176
|
-
const preferredBuilder = req.headers["x-fisk-builder"];
|
|
177
|
-
if (preferredBuilder)
|
|
178
|
-
data.builder = preferredBuilder;
|
|
179
|
-
const labels = req.headers["x-fisk-builder-labels"];
|
|
180
|
-
if (labels) {
|
|
181
|
-
data.labels = labels.split(/ +/).filter(x => x);
|
|
182
|
-
}
|
|
183
|
-
const clientName = req.headers["x-fisk-client-name"];
|
|
184
|
-
if (clientName)
|
|
185
|
-
data.name = clientName;
|
|
186
|
-
const user = req.headers["x-fisk-user"];
|
|
187
|
-
if (user)
|
|
188
|
-
data.user = user;
|
|
189
|
-
const clientHostname = req.headers["x-fisk-client-hostname"];
|
|
190
|
-
if (clientHostname)
|
|
191
|
-
data.hostname = clientHostname;
|
|
192
|
-
Object.assign(client, data);
|
|
193
|
-
this.emit("compile", client);
|
|
194
|
-
let remaining = { bytes: undefined, type: undefined };
|
|
195
|
-
client.ws.on("close", (status, reason) => client.emit("close", status, reason));
|
|
196
|
-
client.ws.on("error", err => client.emit("error", err));
|
|
197
|
-
client.ws.on("close", (code, reason) => {
|
|
198
|
-
if (remaining.bytes)
|
|
199
|
-
client.emit("error", "Got close while reading a binary message");
|
|
200
|
-
if (client)
|
|
201
|
-
client.emit("close", { code: code, reason: reason });
|
|
202
|
-
client.ws.removeAllListeners();
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
client.ws.on("message", msg => {
|
|
206
|
-
switch (typeof msg) {
|
|
207
|
-
case "string":
|
|
208
|
-
if (remaining.bytes) {
|
|
209
|
-
// bad, client have to send all the data in a binary message before sending JSON
|
|
210
|
-
client.error(`Got JSON message while ${remaining.bytes} bytes remained of a binary message`);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
// assume JSON
|
|
214
|
-
let json;
|
|
215
|
-
try {
|
|
216
|
-
json = JSON.parse(msg);
|
|
217
|
-
} catch (e) {
|
|
218
|
-
}
|
|
219
|
-
if (json === undefined) {
|
|
220
|
-
client.error("Unable to parse string message as JSON");
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (json.type == "log") {
|
|
225
|
-
client.emit("log", json);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
if (json.type != "uploadEnvironment") {
|
|
229
|
-
client.error("Expected type: \"uploadEnvironment\"");
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (!("hash" in json)) {
|
|
234
|
-
console.log(json);
|
|
235
|
-
client.error("Need a hash property");
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (!("bytes" in json)) {
|
|
239
|
-
console.log(json);
|
|
240
|
-
client.error("Need a bytes property");
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
remaining.type = "uploadEnvironmentData";
|
|
245
|
-
remaining.bytes = json.bytes;
|
|
246
|
-
|
|
247
|
-
client.emit("uploadEnvironment", json);
|
|
248
|
-
break;
|
|
249
|
-
case "object":
|
|
250
|
-
if (msg instanceof Buffer) {
|
|
251
|
-
if (!msg.length) {
|
|
252
|
-
// no data?
|
|
253
|
-
client.error("No data in buffer");
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (!remaining.bytes) {
|
|
257
|
-
client.error("Got binary message without a preceeding json message describing the data");
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (msg.length > remaining.bytes) {
|
|
261
|
-
// woops
|
|
262
|
-
client.error(`length ${msg.length} > ${remaining.bytes}`);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
remaining.bytes -= msg.length;
|
|
266
|
-
client.emit(remaining.type, { data: msg, last: !remaining.bytes });
|
|
267
|
-
}
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
_handleBuilder(req, client) {
|
|
274
|
-
client.ws.on("close", (code, reason) => {
|
|
275
|
-
client.emit("close", { code: code, reason: reason });
|
|
276
|
-
client.ws.removeAllListeners();
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
client.ws.on("error", (code, reason) => {
|
|
280
|
-
client.emit("close", { code: 1005, reason: "unknown" });
|
|
281
|
-
client.ws.removeAllListeners();
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
if (!("x-fisk-port" in req.headers)) {
|
|
285
|
-
client.error("No x-fisk-port header");
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (!("x-fisk-environments" in req.headers)) {
|
|
290
|
-
client.error("No x-fisk-builder-environment header");
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (!("x-fisk-slots" in req.headers) || !parseInt(req.headers["x-fisk-slots"])) {
|
|
295
|
-
client.error("No x-fisk-slots header");
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const confVersion = req.headers["x-fisk-config-version"];
|
|
300
|
-
if (confVersion != this.configVersion) {
|
|
301
|
-
client.error(`Bad config version, expected ${this.configVersion}, got ${confVersion}`);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const port = parseInt(req.headers["x-fisk-port"]);
|
|
306
|
-
const name = req.headers["x-fisk-builder-name"];
|
|
307
|
-
const hostname = req.headers["x-fisk-builder-hostname"];
|
|
308
|
-
let labels = req.headers["x-fisk-builder-labels"];
|
|
309
|
-
if (labels)
|
|
310
|
-
labels = labels.split(/ +/).filter(x => x);
|
|
311
|
-
const system = req.headers["x-fisk-system"];
|
|
312
|
-
const slots = parseInt(req.headers["x-fisk-slots"]);
|
|
313
|
-
const npmVersion = req.headers["x-fisk-npm-version"];
|
|
314
|
-
let environments = {};
|
|
315
|
-
req.headers["x-fisk-environments"].replace(/\s+/g, "").split(";").forEach(env => {
|
|
316
|
-
if (env)
|
|
317
|
-
environments[env] = true;
|
|
318
|
-
});
|
|
319
|
-
Object.assign(client, {
|
|
320
|
-
port: port,
|
|
321
|
-
name: name,
|
|
322
|
-
labels: labels,
|
|
323
|
-
slots: slots,
|
|
324
|
-
jobsPerformed: 0,
|
|
325
|
-
jobsScheduled: 0,
|
|
326
|
-
totalCompileSpeed: 0,
|
|
327
|
-
totalUploadSpeed: 0,
|
|
328
|
-
lastJob: 0,
|
|
329
|
-
load: 0,
|
|
330
|
-
npmVersion: npmVersion,
|
|
331
|
-
hostname: hostname,
|
|
332
|
-
environments: environments,
|
|
333
|
-
system: system
|
|
334
|
-
});
|
|
335
|
-
client.ws.on("message", msg => {
|
|
336
|
-
// console.log("Got message from builder", typeof msg, msg.length);
|
|
337
|
-
switch (typeof msg) {
|
|
338
|
-
case "string":
|
|
339
|
-
// assume JSON
|
|
340
|
-
let json;
|
|
341
|
-
try {
|
|
342
|
-
json = JSON.parse(msg);
|
|
343
|
-
} catch (e) {
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (json === undefined) {
|
|
347
|
-
client.error("Unable to parse string message as JSON");
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
// console.log("Got message", json);
|
|
351
|
-
if ("type" in json) {
|
|
352
|
-
client.emit(json.type, json);
|
|
353
|
-
} else {
|
|
354
|
-
console.error("Bad message without type", json);
|
|
355
|
-
}
|
|
356
|
-
case "object":
|
|
357
|
-
if (msg instanceof Buffer) {
|
|
358
|
-
client.emit("data", msg);
|
|
359
|
-
}
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
// console.log("Got dude", envs);
|
|
364
|
-
this.emit("builder", client);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
_handleMonitor(req, client) {
|
|
368
|
-
client.nonce = req.nonce;
|
|
369
|
-
// console.log("Got nonce", req.nonce);
|
|
370
|
-
client.ws.on("message", message => client.emit("message", message));
|
|
371
|
-
this.emit("monitor", client);
|
|
372
|
-
client.ws.on("close", (code, reason) => {
|
|
373
|
-
client.ws.removeAllListeners();
|
|
374
|
-
client.emit("close", { code: code, reason: reason });
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
client.ws.on("error", err => client.emit("error", err));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
_handleClientVerify(req, client) {
|
|
381
|
-
Object.assign(client, {npmVersion: req.headers["x-fisk-npm-version"] });
|
|
382
|
-
this.emit("clientVerify", client);
|
|
383
|
-
client.ws.on("close", (code, reason) => {
|
|
384
|
-
client.ws.removeAllListeners();
|
|
385
|
-
client.emit("close", { code: code, reason: reason });
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
client.ws.on("error", err => client.emit("error", err));
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
_handleConnection(ws, req) {
|
|
392
|
-
let client = undefined;
|
|
393
|
-
let ip = req.connection.remoteAddress;
|
|
394
|
-
// console.log("_handleConnection", ip);
|
|
395
|
-
|
|
396
|
-
if (!ip) {
|
|
397
|
-
ws.send("{\"error\": \"no ip for some reason\"}");
|
|
398
|
-
ws.close();
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
if (ip.substr(0, 7) == "::ffff:") {
|
|
402
|
-
ip = ip.substr(7);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
const url = Url.parse(req.url);
|
|
406
|
-
switch (url.pathname) {
|
|
407
|
-
case "/compile":
|
|
408
|
-
client = new Client({ type: Client.Compile, ws: ws, ip: ip });
|
|
409
|
-
this._handleCompile(req, client);
|
|
410
|
-
break;
|
|
411
|
-
case "/builder":
|
|
412
|
-
client = new Client({ type: Client.Builder, ws: ws, ip: ip, option: this.option });
|
|
413
|
-
this._handleBuilder(req, client);
|
|
414
|
-
break;
|
|
415
|
-
case "/monitor":
|
|
416
|
-
client = new Client({ type: Client.Type.Monitor, ws: ws, ip: ip });
|
|
417
|
-
this._handleMonitor(req, client);
|
|
418
|
-
break;
|
|
419
|
-
case "/client_verify":
|
|
420
|
-
client = new Client({ type: Client.Type.ClientVerify, ws: ws, ip: ip });
|
|
421
|
-
this._handleClientVerify(req, client);
|
|
422
|
-
break;
|
|
423
|
-
default:
|
|
424
|
-
console.error(`Invalid pathname ${url.pathname} from: ${ip}`);
|
|
425
|
-
ws.close();
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
module.exports = Server;
|
package/scheduler/usertester.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const WebSocket = require("ws");
|
|
4
|
-
const crypto = require("crypto");
|
|
5
|
-
const argv = require("minimist")(process.argv.slice(2));
|
|
6
|
-
|
|
7
|
-
// console.log("shit");
|
|
8
|
-
const ws = new WebSocket((argv.scheduler || "ws://localhost:8097") + "/monitor");
|
|
9
|
-
ws.on("upgrade", res => {
|
|
10
|
-
// console.log("GOT HEADERS", res.headers);
|
|
11
|
-
ws.nonce = res.headers["x-fisk-nonce"];
|
|
12
|
-
});
|
|
13
|
-
ws.on("open", () => {
|
|
14
|
-
console.log("got open", argv, ws.nonce);
|
|
15
|
-
if (argv.addUser) {
|
|
16
|
-
console.log("addUser");
|
|
17
|
-
ws.send(JSON.stringify({type: "addUser", user: "agbakken@gmail.com", password: "ball1"}));
|
|
18
|
-
} else if (argv.cookie) {
|
|
19
|
-
let hmac = crypto.createHmac("sha512", Buffer.from(argv.cookie, "base64"));
|
|
20
|
-
hmac.write(ws.nonce);
|
|
21
|
-
hmac.end();
|
|
22
|
-
const msg = { type: "login", user: "agbakken@gmail.com", hmac: hmac.read().toString("base64") };
|
|
23
|
-
ws.send(JSON.stringify(msg));
|
|
24
|
-
console.log(`cookie login ${JSON.stringify(msg, null, 4)}`);
|
|
25
|
-
} else if (argv.login) {
|
|
26
|
-
ws.send(JSON.stringify({type: "login", user: "agbakken@gmail.com", password: "ball1"}));
|
|
27
|
-
console.log("login");
|
|
28
|
-
} else if (argv.listUsers) {
|
|
29
|
-
ws.send(JSON.stringify({type: "login", user: "agbakken@gmail.com", password: "ball1"}));
|
|
30
|
-
setTimeout(() => {
|
|
31
|
-
ws.send(JSON.stringify({type: "listUsers"}));
|
|
32
|
-
console.log("listUsers");
|
|
33
|
-
}, 2000);
|
|
34
|
-
} else if (argv.removeUser) {
|
|
35
|
-
ws.send(JSON.stringify({type: "login", "user": "agbakken@gmail.com", "password": "ball1"}));
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
ws.send(JSON.stringify({type: "removeUser", "user": "agbakken@gmail.com"}));
|
|
38
|
-
console.log("removeUser");
|
|
39
|
-
}, 2000);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
ws.on("headers", (headers, res) => {
|
|
43
|
-
console.log("Got headers", headers);
|
|
44
|
-
});
|
|
45
|
-
// setInterval(() => {
|
|
46
|
-
// console.log("fuck");
|
|
47
|
-
// }, 1000);
|
|
48
|
-
ws.on("error", err => {
|
|
49
|
-
console.log("got error", err);
|
|
50
|
-
});
|
|
51
|
-
ws.on("message", msg => {
|
|
52
|
-
console.log("Got message", JSON.stringify(JSON.parse(msg), null, 4));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|