@andersbakken/fisk 3.4.103 → 3.5.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/builder/VM.js +5 -7
- package/builder/client.js +8 -10
- package/builder/fisk-builder.js +22 -15
- package/builder/server.js +19 -9
- package/package.json +1 -1
- package/scheduler/server.js +19 -23
package/builder/VM.js
CHANGED
|
@@ -28,15 +28,13 @@ class CompileJob extends EventEmitter
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
feed(data
|
|
31
|
+
feed(data) {
|
|
32
32
|
fs.writeSync(this.fd, data);
|
|
33
33
|
this.cppSize += data.length;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.vm.child.send({ type: "compile", commandLine: this.commandLine, argv0: this.argv0, id: this.id, dir: this.vmDir}, this.sendCallback.bind(this));
|
|
39
|
-
}
|
|
34
|
+
this.startCompile = Date.now();
|
|
35
|
+
fs.close(this.fd);
|
|
36
|
+
this.fd = undefined;
|
|
37
|
+
this.vm.child.send({ type: "compile", commandLine: this.commandLine, argv0: this.argv0, id: this.id, dir: this.vmDir}, this.sendCallback.bind(this));
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
cancel() {
|
package/builder/client.js
CHANGED
|
@@ -121,18 +121,16 @@ class Client extends EventEmitter {
|
|
|
121
121
|
error("No data in buffer");
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
if (remaining) {
|
|
125
|
-
// more data
|
|
126
|
-
if (msg.length > remaining) {
|
|
127
|
-
// woops
|
|
128
|
-
error(`length ${msg.length} > ${remaining}`);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
remaining -= msg.length;
|
|
132
|
-
this.emit("data", { data: msg, last: !remaining });
|
|
133
|
-
} else {
|
|
124
|
+
if (!remaining) {
|
|
134
125
|
error(`Unexpected binary message of length: ${msg.length}`);
|
|
126
|
+
return;
|
|
127
|
+
} else if (msg.length !== remaining) {
|
|
128
|
+
// woops
|
|
129
|
+
error(`length ${msg.length} !== ${remaining}`);
|
|
130
|
+
return;
|
|
135
131
|
}
|
|
132
|
+
remaining = 0;
|
|
133
|
+
this.emit("data", { data: msg });
|
|
136
134
|
} else {
|
|
137
135
|
error("Unexpected object");
|
|
138
136
|
}
|
package/builder/fisk-builder.js
CHANGED
|
@@ -21,6 +21,7 @@ const VM = require("./VM");
|
|
|
21
21
|
const load = require("./load");
|
|
22
22
|
const ObjectCache = require("./objectcache");
|
|
23
23
|
const quitOnError = require("./quit-on-error")(option);
|
|
24
|
+
const zlib = require("zlib");
|
|
24
25
|
|
|
25
26
|
if (process.getuid() !== 0) {
|
|
26
27
|
console.error("fisk builder needs to run as root to be able to chroot");
|
|
@@ -652,7 +653,7 @@ server.on("job", job => {
|
|
|
652
653
|
aborted: false,
|
|
653
654
|
started: false,
|
|
654
655
|
heartbeatTimer: undefined,
|
|
655
|
-
|
|
656
|
+
buffer: undefined,
|
|
656
657
|
stdout: "",
|
|
657
658
|
stderr: "",
|
|
658
659
|
start: function() {
|
|
@@ -713,11 +714,13 @@ server.on("job", job => {
|
|
|
713
714
|
|
|
714
715
|
console.log("Starting job", j.id, job.sourceFile, "for", job.ip, job.name, "wait", job.wait);
|
|
715
716
|
j.op = vm.startCompile(job.commandLine, job.argv0, job.id);
|
|
716
|
-
|
|
717
|
+
if (j.buffer) {
|
|
718
|
+
j.op.feed(j.buffer);
|
|
719
|
+
j.buffer = undefined;
|
|
720
|
+
}
|
|
717
721
|
if (job.wait) {
|
|
718
722
|
job.send("resume", {});
|
|
719
723
|
}
|
|
720
|
-
delete j.buffers;
|
|
721
724
|
j.op.on("stdout", data => { j.stdout += data; }); // ### is there ever any stdout? If there is, does the order matter for stdout vs stderr?
|
|
722
725
|
j.op.on("stderr", data => { j.stderr += data; });
|
|
723
726
|
j.op.on("finished", event => {
|
|
@@ -735,7 +738,11 @@ server.on("job", job => {
|
|
|
735
738
|
}
|
|
736
739
|
|
|
737
740
|
// this can't be async, the directory is removed after the event is fired
|
|
738
|
-
|
|
741
|
+
const forCache = event.files.map(f => ({ contents: fs.readFileSync(f.absolute), path: f.path }));
|
|
742
|
+
const contents = !j.job.compressed ? forCache : forCache.map(x => ({
|
|
743
|
+
path: x.path,
|
|
744
|
+
contents: x.contents.byteLength ? zlib.gzipSync(x.contents) : x.contents
|
|
745
|
+
}));
|
|
739
746
|
let response = {
|
|
740
747
|
type: "response",
|
|
741
748
|
index: contents.map(item => { return { path: item.path, bytes: item.contents.length }; }),
|
|
@@ -755,13 +762,14 @@ server.on("job", job => {
|
|
|
755
762
|
response.sourceFile = job.sourceFile;
|
|
756
763
|
response.commandLine = job.commandLine;
|
|
757
764
|
response.environment = job.hash;
|
|
758
|
-
objectCache.add(response,
|
|
765
|
+
objectCache.add(response, forCache);
|
|
759
766
|
}
|
|
760
767
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
768
|
+
contents.forEach(x => {
|
|
769
|
+
if (x.contents.byteLength) {
|
|
770
|
+
job.send(x.contents);
|
|
771
|
+
}
|
|
772
|
+
});
|
|
765
773
|
// console.log("GOT ID", j);
|
|
766
774
|
if (event.success) {
|
|
767
775
|
client.send("jobFinished", {
|
|
@@ -822,14 +830,13 @@ server.on("job", job => {
|
|
|
822
830
|
});
|
|
823
831
|
|
|
824
832
|
job.on("data", data => {
|
|
825
|
-
// console.log("got data", this.id,
|
|
826
|
-
|
|
827
|
-
uploadDuration = Date.now() - jobStartTime;
|
|
833
|
+
// console.log("got data", this.id, typeof j.op);
|
|
834
|
+
uploadDuration = Date.now() - jobStartTime;
|
|
828
835
|
if (!j.op) {
|
|
829
|
-
j.
|
|
830
|
-
console.log("buffering...", j.
|
|
836
|
+
j.buffer = data.data;
|
|
837
|
+
console.log("buffering...", j.buffer.byteLength);
|
|
831
838
|
} else {
|
|
832
|
-
j.op.feed(data.data
|
|
839
|
+
j.op.feed(data.data);
|
|
833
840
|
}
|
|
834
841
|
});
|
|
835
842
|
|
package/builder/server.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
1
|
const EventEmitter = require("events");
|
|
3
2
|
const WebSocket = require("ws");
|
|
4
3
|
const Url = require("url");
|
|
5
4
|
const http = require("http");
|
|
6
5
|
const express = require("express");
|
|
6
|
+
const zlib = require("zlib");
|
|
7
7
|
|
|
8
8
|
class Job extends EventEmitter {
|
|
9
9
|
constructor(data) {
|
|
10
10
|
super();
|
|
11
|
-
|
|
12
|
-
this[key] = data[key];
|
|
11
|
+
Object.assign(this, data);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
send(type, msg) {
|
|
@@ -154,6 +153,7 @@ class Server extends EventEmitter {
|
|
|
154
153
|
return;
|
|
155
154
|
}
|
|
156
155
|
bytes = json.bytes;
|
|
156
|
+
client.compressed = json.compressed;
|
|
157
157
|
client.commandLine = json.commandLine;
|
|
158
158
|
client.argv0 = json.argv0;
|
|
159
159
|
client.connectTime = connectTime;
|
|
@@ -166,21 +166,31 @@ class Server extends EventEmitter {
|
|
|
166
166
|
// console.log("Got binary", msg.length, bytes);
|
|
167
167
|
if (!msg.length) {
|
|
168
168
|
// no data?
|
|
169
|
-
|
|
169
|
+
error("No data in buffer");
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
if (!bytes) {
|
|
173
173
|
error("Got binary message without a preceeding json message describing the data");
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
if (msg.length
|
|
176
|
+
if (msg.length !== bytes) {
|
|
177
177
|
// woops
|
|
178
|
-
error(`length ${msg.length}
|
|
178
|
+
error(`length ${msg.length} !== ${bytes}`);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
|
-
bytes
|
|
182
|
-
// console.log("
|
|
183
|
-
client.
|
|
181
|
+
bytes = 0;
|
|
182
|
+
// console.log("GOT DATA", client.compressed, msg.length);
|
|
183
|
+
if (client.compressed) {
|
|
184
|
+
zlib.gunzip(msg, (err, data) => {
|
|
185
|
+
if (err) {
|
|
186
|
+
error(`Got error inflating data ${err}`);
|
|
187
|
+
} else {
|
|
188
|
+
client.emit("data", { data });
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
client.emit("data", { data: msg });
|
|
193
|
+
}
|
|
184
194
|
}
|
|
185
195
|
break;
|
|
186
196
|
}
|
package/package.json
CHANGED
package/scheduler/server.js
CHANGED
|
@@ -10,7 +10,7 @@ class Client extends EventEmitter {
|
|
|
10
10
|
constructor(object) {
|
|
11
11
|
super();
|
|
12
12
|
this.created = new Date();
|
|
13
|
-
|
|
13
|
+
Object.assign(this, object);
|
|
14
14
|
this.pingSent = undefined;
|
|
15
15
|
this.ws.on("pong", () => {
|
|
16
16
|
// console.log("got pong", this.name);
|
|
@@ -18,12 +18,6 @@ class Client extends EventEmitter {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
assign(object) {
|
|
22
|
-
for (let key in object) {
|
|
23
|
-
this[key] = object[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
send(type, msg) {
|
|
28
22
|
try {
|
|
29
23
|
if (msg === undefined) {
|
|
@@ -188,7 +182,7 @@ class Server extends EventEmitter {
|
|
|
188
182
|
const clientHostname = req.headers["x-fisk-client-hostname"];
|
|
189
183
|
if (clientHostname)
|
|
190
184
|
data.hostname = clientHostname;
|
|
191
|
-
|
|
185
|
+
Object.assign(client, data);
|
|
192
186
|
this.emit("compile", client);
|
|
193
187
|
let remaining = { bytes: undefined, type: undefined };
|
|
194
188
|
client.ws.on("close", (status, reason) => client.emit("close", status, reason));
|
|
@@ -315,20 +309,22 @@ class Server extends EventEmitter {
|
|
|
315
309
|
if (env)
|
|
316
310
|
environments[env] = true;
|
|
317
311
|
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
312
|
+
Object.assign(client, {
|
|
313
|
+
port: port,
|
|
314
|
+
name: name,
|
|
315
|
+
labels: labels,
|
|
316
|
+
slots: slots,
|
|
317
|
+
jobsPerformed: 0,
|
|
318
|
+
jobsScheduled: 0,
|
|
319
|
+
totalCompileSpeed: 0,
|
|
320
|
+
totalUploadSpeed: 0,
|
|
321
|
+
lastJob: 0,
|
|
322
|
+
load: 0,
|
|
323
|
+
npmVersion: npmVersion,
|
|
324
|
+
hostname: hostname,
|
|
325
|
+
environments: environments,
|
|
326
|
+
system: system
|
|
327
|
+
});
|
|
332
328
|
client.ws.on("message", msg => {
|
|
333
329
|
// console.log("Got message from builder", typeof msg, msg.length);
|
|
334
330
|
switch (typeof msg) {
|
|
@@ -375,7 +371,7 @@ class Server extends EventEmitter {
|
|
|
375
371
|
}
|
|
376
372
|
|
|
377
373
|
_handleClientVerify(req, client) {
|
|
378
|
-
|
|
374
|
+
Object.assign(client, {npmVersion: req.headers["x-fisk-npm-version"] });
|
|
379
375
|
this.emit("clientVerify", client);
|
|
380
376
|
client.ws.on("close", (code, reason) => {
|
|
381
377
|
client.ws.removeAllListeners();
|