@andersbakken/fisk 4.0.61 → 4.0.62
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_runtime.js +42 -45
- package/builder/fisk-builder.js +15414 -20314
- package/daemon/fisk-daemon.js +36 -231
- package/monitor/fisk-monitor.js +123 -635
- package/package.json +2 -2
- package/scheduler/fisk-scheduler.js +4278 -8162
package/daemon/fisk-daemon.js
CHANGED
|
@@ -7,10 +7,10 @@ var require$$0 = require('constants');
|
|
|
7
7
|
var require$$0$1 = require('stream');
|
|
8
8
|
var require$$4 = require('util');
|
|
9
9
|
var assert$1 = require('assert');
|
|
10
|
-
var
|
|
10
|
+
var require$$1$1 = require('path');
|
|
11
11
|
var os$1 = require('os');
|
|
12
12
|
var net = require('net');
|
|
13
|
-
var require$$1$
|
|
13
|
+
var require$$1$2 = require('module');
|
|
14
14
|
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
16
|
|
|
@@ -20,10 +20,10 @@ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
|
20
20
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
21
21
|
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
22
22
|
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1);
|
|
23
|
-
var
|
|
23
|
+
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
24
24
|
var os__default = /*#__PURE__*/_interopDefaultLegacy(os$1);
|
|
25
25
|
var net__default = /*#__PURE__*/_interopDefaultLegacy(net);
|
|
26
|
-
var require$$1__default$
|
|
26
|
+
var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
27
27
|
|
|
28
28
|
const Constants = {
|
|
29
29
|
// client codes
|
|
@@ -42,12 +42,6 @@ const Constants = {
|
|
|
42
42
|
get JSON() {
|
|
43
43
|
return 5;
|
|
44
44
|
},
|
|
45
|
-
get AcquireSlot() {
|
|
46
|
-
return 6;
|
|
47
|
-
},
|
|
48
|
-
get ReleaseLocalSlot() {
|
|
49
|
-
return 7;
|
|
50
|
-
},
|
|
51
45
|
// daemon codes
|
|
52
46
|
get CppSlotAcquired() {
|
|
53
47
|
return 10;
|
|
@@ -57,9 +51,6 @@ const Constants = {
|
|
|
57
51
|
},
|
|
58
52
|
get JSONResponse() {
|
|
59
53
|
return 12;
|
|
60
|
-
},
|
|
61
|
-
get LocalSlotAcquired() {
|
|
62
|
-
return 13;
|
|
63
54
|
}
|
|
64
55
|
};
|
|
65
56
|
|
|
@@ -217,12 +208,6 @@ class Compile extends EventEmitter__default["default"] {
|
|
|
217
208
|
case Constants.ReleaseCompileSlot:
|
|
218
209
|
emit("releaseCompileSlot");
|
|
219
210
|
continue;
|
|
220
|
-
case Constants.AcquireSlot:
|
|
221
|
-
emit("acquireSlot");
|
|
222
|
-
continue;
|
|
223
|
-
case Constants.ReleaseLocalSlot:
|
|
224
|
-
emit("releaseLocalSlot");
|
|
225
|
-
continue;
|
|
226
211
|
case Constants.JSON:
|
|
227
212
|
if (available < 5) {
|
|
228
213
|
break;
|
|
@@ -1347,7 +1332,7 @@ function retry () {
|
|
|
1347
1332
|
};
|
|
1348
1333
|
} (fs$j));
|
|
1349
1334
|
|
|
1350
|
-
const path$g =
|
|
1335
|
+
const path$g = require$$1__default$1["default"];
|
|
1351
1336
|
|
|
1352
1337
|
// get drive on windows
|
|
1353
1338
|
function getRootPath (p) {
|
|
@@ -1372,7 +1357,7 @@ var win32 = {
|
|
|
1372
1357
|
};
|
|
1373
1358
|
|
|
1374
1359
|
const fs$h = gracefulFs;
|
|
1375
|
-
const path$f =
|
|
1360
|
+
const path$f = require$$1__default$1["default"];
|
|
1376
1361
|
const invalidWin32Path$1 = win32.invalidWin32Path;
|
|
1377
1362
|
|
|
1378
1363
|
const o777$1 = parseInt('0777', 8);
|
|
@@ -1434,7 +1419,7 @@ function mkdirs$2 (p, opts, callback, made) {
|
|
|
1434
1419
|
var mkdirs_1$1 = mkdirs$2;
|
|
1435
1420
|
|
|
1436
1421
|
const fs$g = gracefulFs;
|
|
1437
|
-
const path$e =
|
|
1422
|
+
const path$e = require$$1__default$1["default"];
|
|
1438
1423
|
const invalidWin32Path = win32.invalidWin32Path;
|
|
1439
1424
|
|
|
1440
1425
|
const o777 = parseInt('0777', 8);
|
|
@@ -1502,7 +1487,7 @@ var mkdirs_1 = {
|
|
|
1502
1487
|
|
|
1503
1488
|
const fs$f = gracefulFs;
|
|
1504
1489
|
const os = os__default["default"];
|
|
1505
|
-
const path$d =
|
|
1490
|
+
const path$d = require$$1__default$1["default"];
|
|
1506
1491
|
|
|
1507
1492
|
// HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
|
|
1508
1493
|
function hasMillisResSync () {
|
|
@@ -1591,7 +1576,7 @@ var buffer$1 = function (size) {
|
|
|
1591
1576
|
};
|
|
1592
1577
|
|
|
1593
1578
|
const fs$e = gracefulFs;
|
|
1594
|
-
const path$c =
|
|
1579
|
+
const path$c = require$$1__default$1["default"];
|
|
1595
1580
|
const mkdirpSync$1 = mkdirs_1.mkdirsSync;
|
|
1596
1581
|
const utimesSync = utimes$1.utimesMillisSync;
|
|
1597
1582
|
|
|
@@ -1825,7 +1810,7 @@ var pathExists_1 = {
|
|
|
1825
1810
|
};
|
|
1826
1811
|
|
|
1827
1812
|
const fs$c = gracefulFs;
|
|
1828
|
-
const path$b =
|
|
1813
|
+
const path$b = require$$1__default$1["default"];
|
|
1829
1814
|
const mkdirp$1 = mkdirs_1.mkdirs;
|
|
1830
1815
|
const pathExists$7 = pathExists_1.pathExists;
|
|
1831
1816
|
const utimes = utimes$1.utimesMillis;
|
|
@@ -2105,7 +2090,7 @@ var copy$1 = {
|
|
|
2105
2090
|
};
|
|
2106
2091
|
|
|
2107
2092
|
const fs$b = gracefulFs;
|
|
2108
|
-
const path$a =
|
|
2093
|
+
const path$a = require$$1__default$1["default"];
|
|
2109
2094
|
const assert = assert__default["default"];
|
|
2110
2095
|
|
|
2111
2096
|
const isWindows = (process.platform === 'win32');
|
|
@@ -2427,7 +2412,7 @@ var remove$2 = {
|
|
|
2427
2412
|
|
|
2428
2413
|
const u$7 = universalify.fromCallback;
|
|
2429
2414
|
const fs$a = require$$1__default["default"];
|
|
2430
|
-
const path$9 =
|
|
2415
|
+
const path$9 = require$$1__default$1["default"];
|
|
2431
2416
|
const mkdir$5 = mkdirs_1;
|
|
2432
2417
|
const remove$1 = remove$2;
|
|
2433
2418
|
|
|
@@ -2473,7 +2458,7 @@ var empty = {
|
|
|
2473
2458
|
};
|
|
2474
2459
|
|
|
2475
2460
|
const u$6 = universalify.fromCallback;
|
|
2476
|
-
const path$8 =
|
|
2461
|
+
const path$8 = require$$1__default$1["default"];
|
|
2477
2462
|
const fs$9 = gracefulFs;
|
|
2478
2463
|
const mkdir$4 = mkdirs_1;
|
|
2479
2464
|
const pathExists$6 = pathExists_1.pathExists;
|
|
@@ -2521,7 +2506,7 @@ var file$1 = {
|
|
|
2521
2506
|
};
|
|
2522
2507
|
|
|
2523
2508
|
const u$5 = universalify.fromCallback;
|
|
2524
|
-
const path$7 =
|
|
2509
|
+
const path$7 = require$$1__default$1["default"];
|
|
2525
2510
|
const fs$8 = gracefulFs;
|
|
2526
2511
|
const mkdir$3 = mkdirs_1;
|
|
2527
2512
|
const pathExists$5 = pathExists_1.pathExists;
|
|
@@ -2580,7 +2565,7 @@ var link$1 = {
|
|
|
2580
2565
|
createLinkSync
|
|
2581
2566
|
};
|
|
2582
2567
|
|
|
2583
|
-
const path$6 =
|
|
2568
|
+
const path$6 = require$$1__default$1["default"];
|
|
2584
2569
|
const fs$7 = gracefulFs;
|
|
2585
2570
|
const pathExists$4 = pathExists_1.pathExists;
|
|
2586
2571
|
|
|
@@ -2709,7 +2694,7 @@ var symlinkType_1 = {
|
|
|
2709
2694
|
};
|
|
2710
2695
|
|
|
2711
2696
|
const u$4 = universalify.fromCallback;
|
|
2712
|
-
const path$5 =
|
|
2697
|
+
const path$5 = require$$1__default$1["default"];
|
|
2713
2698
|
const fs$5 = gracefulFs;
|
|
2714
2699
|
const _mkdirs = mkdirs_1;
|
|
2715
2700
|
const mkdirs = _mkdirs.mkdirs;
|
|
@@ -2938,7 +2923,7 @@ var jsonfile = {
|
|
|
2938
2923
|
writeJsonSync: jsonFile$3.writeFileSync
|
|
2939
2924
|
};
|
|
2940
2925
|
|
|
2941
|
-
const path$4 =
|
|
2926
|
+
const path$4 = require$$1__default$1["default"];
|
|
2942
2927
|
const mkdir$2 = mkdirs_1;
|
|
2943
2928
|
const pathExists$2 = pathExists_1.pathExists;
|
|
2944
2929
|
const jsonFile$2 = jsonfile;
|
|
@@ -2965,7 +2950,7 @@ function outputJson (file, data, options, callback) {
|
|
|
2965
2950
|
var outputJson_1 = outputJson;
|
|
2966
2951
|
|
|
2967
2952
|
const fs$4 = gracefulFs;
|
|
2968
|
-
const path$3 =
|
|
2953
|
+
const path$3 = require$$1__default$1["default"];
|
|
2969
2954
|
const mkdir$1 = mkdirs_1;
|
|
2970
2955
|
const jsonFile$1 = jsonfile;
|
|
2971
2956
|
|
|
@@ -2997,7 +2982,7 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
|
2997
2982
|
var json = jsonFile;
|
|
2998
2983
|
|
|
2999
2984
|
const fs$3 = gracefulFs;
|
|
3000
|
-
const path$2 =
|
|
2985
|
+
const path$2 = require$$1__default$1["default"];
|
|
3001
2986
|
const copySync = copySync$1.copySync;
|
|
3002
2987
|
const removeSync = remove$2.removeSync;
|
|
3003
2988
|
const mkdirpSync = mkdirs_1.mkdirsSync;
|
|
@@ -3114,7 +3099,7 @@ var moveSync_1 = {
|
|
|
3114
3099
|
|
|
3115
3100
|
const u$1 = universalify.fromCallback;
|
|
3116
3101
|
const fs$2 = gracefulFs;
|
|
3117
|
-
const path$1 =
|
|
3102
|
+
const path$1 = require$$1__default$1["default"];
|
|
3118
3103
|
const copy = copy$1.copy;
|
|
3119
3104
|
const remove = remove$2.remove;
|
|
3120
3105
|
const mkdirp = mkdirs_1.mkdirp;
|
|
@@ -3195,7 +3180,7 @@ var move_1 = {
|
|
|
3195
3180
|
|
|
3196
3181
|
const u = universalify.fromCallback;
|
|
3197
3182
|
const fs$1 = gracefulFs;
|
|
3198
|
-
const path =
|
|
3183
|
+
const path = require$$1__default$1["default"];
|
|
3199
3184
|
const mkdir = mkdirs_1;
|
|
3200
3185
|
const pathExists = pathExists_1.pathExists;
|
|
3201
3186
|
|
|
@@ -3269,7 +3254,7 @@ class Server extends EventEmitter__default["default"] {
|
|
|
3269
3254
|
super();
|
|
3270
3255
|
this.option = option;
|
|
3271
3256
|
this.debug = option("debug");
|
|
3272
|
-
this.file = option("socket",
|
|
3257
|
+
this.file = option("socket", require$$1__default$1["default"].join(common.cacheDir(), "socket"));
|
|
3273
3258
|
this.server = undefined;
|
|
3274
3259
|
this.option = option;
|
|
3275
3260
|
this._connections = {};
|
|
@@ -3345,40 +3330,16 @@ class Slots extends EventEmitter__default["default"] {
|
|
|
3345
3330
|
this.debug = debug;
|
|
3346
3331
|
this.used = new Map();
|
|
3347
3332
|
this.pending = new Map();
|
|
3348
|
-
this._totalAcquired = 0;
|
|
3349
3333
|
if (this.debug) {
|
|
3350
3334
|
console.log("Slots created", this.toString());
|
|
3351
3335
|
}
|
|
3352
3336
|
}
|
|
3353
|
-
get capacity() {
|
|
3354
|
-
return this.count;
|
|
3355
|
-
}
|
|
3356
|
-
get active() {
|
|
3357
|
-
return this.used.size;
|
|
3358
|
-
}
|
|
3359
|
-
get totalAcquired() {
|
|
3360
|
-
return this._totalAcquired;
|
|
3361
|
-
}
|
|
3362
|
-
tryAcquire(id, data) {
|
|
3363
|
-
if (this.used.size < this.count) {
|
|
3364
|
-
this.used.set(id, data);
|
|
3365
|
-
++this._totalAcquired;
|
|
3366
|
-
if (this.debug) {
|
|
3367
|
-
console.log("tryAcquire succeeded", id, data, this.toString());
|
|
3368
|
-
}
|
|
3369
|
-
this.emit("changed");
|
|
3370
|
-
return true;
|
|
3371
|
-
}
|
|
3372
|
-
return false;
|
|
3373
|
-
}
|
|
3374
3337
|
acquire(id, data, cb) {
|
|
3375
3338
|
if (this.used.size < this.count) {
|
|
3376
3339
|
this.used.set(id, data);
|
|
3377
|
-
++this._totalAcquired;
|
|
3378
3340
|
if (this.debug) {
|
|
3379
3341
|
console.log("acquired slot", id, data, this.toString());
|
|
3380
3342
|
}
|
|
3381
|
-
this.emit("changed");
|
|
3382
3343
|
cb();
|
|
3383
3344
|
}
|
|
3384
3345
|
else {
|
|
@@ -3402,11 +3363,9 @@ class Slots extends EventEmitter__default["default"] {
|
|
|
3402
3363
|
for (const p of this.pending) {
|
|
3403
3364
|
this.used.set(p[0], p[1].data);
|
|
3404
3365
|
this.pending.delete(p[0]);
|
|
3405
|
-
++this._totalAcquired;
|
|
3406
3366
|
p[1].cb();
|
|
3407
3367
|
break;
|
|
3408
3368
|
}
|
|
3409
|
-
this.emit("changed");
|
|
3410
3369
|
}
|
|
3411
3370
|
}
|
|
3412
3371
|
toString() {
|
|
@@ -3426,17 +3385,16 @@ class Slots extends EventEmitter__default["default"] {
|
|
|
3426
3385
|
}
|
|
3427
3386
|
|
|
3428
3387
|
const Version = 5;
|
|
3429
|
-
const ObjectCacheFormatVersion = 2;
|
|
3430
3388
|
function cacheDir(option) {
|
|
3431
3389
|
let dir = option("cache-dir");
|
|
3432
3390
|
if (!dir) {
|
|
3433
|
-
dir =
|
|
3391
|
+
dir = require$$1__default$1["default"].join(os__default["default"].homedir(), ".cache", "fisk", require$$1__default$1["default"].basename(option.prefix || ""));
|
|
3434
3392
|
}
|
|
3435
3393
|
return dir;
|
|
3436
3394
|
}
|
|
3437
3395
|
function validateCache(option) {
|
|
3438
3396
|
const dir = cacheDir(option);
|
|
3439
|
-
const file =
|
|
3397
|
+
const file = require$$1__default$1["default"].join(dir, "version");
|
|
3440
3398
|
// console.log(dir);
|
|
3441
3399
|
let version;
|
|
3442
3400
|
try {
|
|
@@ -3457,36 +3415,11 @@ function validateCache(option) {
|
|
|
3457
3415
|
buf.writeUInt32BE(Version);
|
|
3458
3416
|
fs.writeFileSync(file, buf);
|
|
3459
3417
|
}
|
|
3460
|
-
function validateObjectCache(option) {
|
|
3461
|
-
const dir = cacheDir(option);
|
|
3462
|
-
const objectCacheDir = option.string("object-cache-dir") || path__default["default"].join(dir, "objectcache");
|
|
3463
|
-
const file = path__default["default"].join(objectCacheDir, "version");
|
|
3464
|
-
let version;
|
|
3465
|
-
try {
|
|
3466
|
-
version = fs.readFileSync(file);
|
|
3467
|
-
if (version.readUInt32BE() === ObjectCacheFormatVersion) {
|
|
3468
|
-
return;
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
catch (err) {
|
|
3472
|
-
/* */
|
|
3473
|
-
}
|
|
3474
|
-
if (version) {
|
|
3475
|
-
console.log(`Wrong object cache version. Destroying object cache ${objectCacheDir}`);
|
|
3476
|
-
}
|
|
3477
|
-
fs.removeSync(objectCacheDir);
|
|
3478
|
-
fs.mkdirpSync(objectCacheDir);
|
|
3479
|
-
const buf = Buffer.allocUnsafe(4);
|
|
3480
|
-
buf.writeUInt32BE(ObjectCacheFormatVersion);
|
|
3481
|
-
fs.writeFileSync(file, buf);
|
|
3482
|
-
}
|
|
3483
3418
|
function common$1(option) {
|
|
3484
3419
|
validateCache(option);
|
|
3485
|
-
validateObjectCache(option);
|
|
3486
3420
|
return {
|
|
3487
3421
|
cacheDir: cacheDir.bind(undefined, option),
|
|
3488
|
-
Version
|
|
3489
|
-
ObjectCacheFormatVersion
|
|
3422
|
+
Version
|
|
3490
3423
|
};
|
|
3491
3424
|
}
|
|
3492
3425
|
|
|
@@ -3498,10 +3431,10 @@ function requireResolve () {
|
|
|
3498
3431
|
hasRequiredResolve = 1;
|
|
3499
3432
|
|
|
3500
3433
|
// Dependencies
|
|
3501
|
-
var path =
|
|
3434
|
+
var path = require$$1__default$1["default"];
|
|
3502
3435
|
|
|
3503
3436
|
// Load global paths
|
|
3504
|
-
var globalPaths = require$$1__default$
|
|
3437
|
+
var globalPaths = require$$1__default$2["default"].globalPaths;
|
|
3505
3438
|
|
|
3506
3439
|
// Guess at NPM's global install dir
|
|
3507
3440
|
var npmGlobalPrefix;
|
|
@@ -3591,7 +3524,7 @@ function requireResolve () {
|
|
|
3591
3524
|
}
|
|
3592
3525
|
|
|
3593
3526
|
var appRootPath$1 = function(dirname) {
|
|
3594
|
-
var path =
|
|
3527
|
+
var path = require$$1__default$1["default"];
|
|
3595
3528
|
var resolve = requireResolve();
|
|
3596
3529
|
var appRootPath = resolve(dirname);
|
|
3597
3530
|
|
|
@@ -3626,7 +3559,7 @@ var xdgBasedir = {};
|
|
|
3626
3559
|
|
|
3627
3560
|
(function (exports) {
|
|
3628
3561
|
const os = os__default["default"];
|
|
3629
|
-
const path =
|
|
3562
|
+
const path = require$$1__default$1["default"];
|
|
3630
3563
|
|
|
3631
3564
|
const home = os.homedir();
|
|
3632
3565
|
const env = process.env;
|
|
@@ -3998,7 +3931,7 @@ class Engine {
|
|
|
3998
3931
|
_homedir() {
|
|
3999
3932
|
let home = process.env.home;
|
|
4000
3933
|
if (home) {
|
|
4001
|
-
return
|
|
3934
|
+
return require$$1__default$1["default"].join(home, ".config");
|
|
4002
3935
|
}
|
|
4003
3936
|
return undefined;
|
|
4004
3937
|
}
|
|
@@ -4033,12 +3966,12 @@ class Engine {
|
|
|
4033
3966
|
return 0 /* OptionsReadResult.Failed */;
|
|
4034
3967
|
};
|
|
4035
3968
|
// console.log("about to read file", file, "additionalFiles", this.additionalFiles, "configDirs", this.configDirs, "applicationPath", this.applicationPath, "homedir", this._homedir());
|
|
4036
|
-
if (
|
|
3969
|
+
if (require$$1__default$1["default"].isAbsolute(file)) {
|
|
4037
3970
|
read(file);
|
|
4038
3971
|
}
|
|
4039
3972
|
else {
|
|
4040
3973
|
this.additionalFiles.forEach(file => {
|
|
4041
|
-
if (
|
|
3974
|
+
if (require$$1__default$1["default"].isAbsolute(file) && read(file) == 0 /* OptionsReadResult.Failed */) {
|
|
4042
3975
|
read(file + ".conf");
|
|
4043
3976
|
}
|
|
4044
3977
|
});
|
|
@@ -4048,13 +3981,13 @@ class Engine {
|
|
|
4048
3981
|
return;
|
|
4049
3982
|
}
|
|
4050
3983
|
this.additionalFiles.forEach(additional => {
|
|
4051
|
-
if (!
|
|
4052
|
-
let file =
|
|
3984
|
+
if (!require$$1__default$1["default"].isAbsolute(additional)) {
|
|
3985
|
+
let file = require$$1__default$1["default"].join(root, additional);
|
|
4053
3986
|
if (read(file) == 0 /* OptionsReadResult.Failed */)
|
|
4054
3987
|
read(file + ".conf");
|
|
4055
3988
|
}
|
|
4056
3989
|
});
|
|
4057
|
-
let filePath =
|
|
3990
|
+
let filePath = require$$1__default$1["default"].join(root, file);
|
|
4058
3991
|
if (read(filePath) == 0 /* OptionsReadResult.Failed */) {
|
|
4059
3992
|
read(filePath + ".conf");
|
|
4060
3993
|
}
|
|
@@ -4151,22 +4084,6 @@ function createOptions (optionsOptions, argv) {
|
|
|
4151
4084
|
});
|
|
4152
4085
|
}
|
|
4153
4086
|
|
|
4154
|
-
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
4155
|
-
console.log(`Usage: fisk-daemon [options]
|
|
4156
|
-
|
|
4157
|
-
Options:
|
|
4158
|
-
--debug Enable debug logging
|
|
4159
|
-
--socket=PATH Unix socket path (default: ~/.cache/fisk/daemon/socket)
|
|
4160
|
-
--cpp-slots=N Preprocess slot count (default: cpus * 2)
|
|
4161
|
-
--slots=N Compile slot count (default: cpus)
|
|
4162
|
-
--local-slots=N Local compile slot count (default: 0, disabled)
|
|
4163
|
-
--local-slots-max-load=N Max system load average (1-min) to allow local compiles (default: 0, no limit)
|
|
4164
|
-
--cache-dir=PATH Cache directory (default: ~/.cache/fisk/daemon)
|
|
4165
|
-
|
|
4166
|
-
Config files: ~/.config/fisk/daemon.conf, /etc/xdg/fisk/daemon.conf
|
|
4167
|
-
Environment variables: FISK_DAEMON_DEBUG, FISK_DAEMON_SLOTS, etc.`);
|
|
4168
|
-
process.exit(0);
|
|
4169
|
-
}
|
|
4170
4087
|
const option = createOptions({
|
|
4171
4088
|
prefix: "fisk/daemon",
|
|
4172
4089
|
noApplicationPath: true,
|
|
@@ -4196,87 +4113,15 @@ server.on("error", (err) => {
|
|
|
4196
4113
|
});
|
|
4197
4114
|
const cppSlots = new Slots(option.int("cpp-slots", Math.max(os__default["default"].cpus().length * 2, 1)), "cpp", debug);
|
|
4198
4115
|
const compileSlots = new Slots(option.int("slots", Math.max(os__default["default"].cpus().length, 1)), "compile", debug);
|
|
4199
|
-
const localSlotCount = option.int("local-slots", 0);
|
|
4200
|
-
const localSlots = new Slots(localSlotCount, "local", debug);
|
|
4201
|
-
const localSlotsMaxLoad = option("local-slots-max-load") || 0;
|
|
4202
|
-
const slotSubscribers = [];
|
|
4203
|
-
function slotsInfo() {
|
|
4204
|
-
return {
|
|
4205
|
-
type: "slotsInfo",
|
|
4206
|
-
local: {
|
|
4207
|
-
active: localSlots.active,
|
|
4208
|
-
capacity: localSlots.capacity,
|
|
4209
|
-
total: localSlots.totalAcquired
|
|
4210
|
-
},
|
|
4211
|
-
cpp: {
|
|
4212
|
-
active: cppSlots.active,
|
|
4213
|
-
capacity: cppSlots.capacity,
|
|
4214
|
-
total: cppSlots.totalAcquired
|
|
4215
|
-
},
|
|
4216
|
-
compile: {
|
|
4217
|
-
active: compileSlots.active,
|
|
4218
|
-
capacity: compileSlots.capacity,
|
|
4219
|
-
total: compileSlots.totalAcquired
|
|
4220
|
-
}
|
|
4221
|
-
};
|
|
4222
|
-
}
|
|
4223
|
-
function broadcastSlotsInfo() {
|
|
4224
|
-
if (slotSubscribers.length === 0) {
|
|
4225
|
-
return;
|
|
4226
|
-
}
|
|
4227
|
-
const info = slotsInfo();
|
|
4228
|
-
for (const sub of slotSubscribers) {
|
|
4229
|
-
sub.compile.send(info);
|
|
4230
|
-
}
|
|
4231
|
-
}
|
|
4232
|
-
for (const slots of [localSlots, cppSlots, compileSlots]) {
|
|
4233
|
-
slots.on("changed", broadcastSlotsInfo);
|
|
4234
|
-
}
|
|
4235
|
-
function canAcquireLocalSlot() {
|
|
4236
|
-
if (localSlotCount <= 0) {
|
|
4237
|
-
return false;
|
|
4238
|
-
}
|
|
4239
|
-
if (localSlotsMaxLoad > 0) {
|
|
4240
|
-
const loadAvg = os__default["default"].loadavg()[0];
|
|
4241
|
-
if (loadAvg > localSlotsMaxLoad) {
|
|
4242
|
-
if (debug) {
|
|
4243
|
-
console.log(`Local slot denied: load ${loadAvg.toFixed(2)} > max ${localSlotsMaxLoad}`);
|
|
4244
|
-
}
|
|
4245
|
-
return false;
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
return true;
|
|
4249
|
-
}
|
|
4250
4116
|
server.on("compile", (compile) => {
|
|
4251
4117
|
compile.on("dumpSlots", () => {
|
|
4252
|
-
const ret = { cpp: cppSlots.dump(), compile: compileSlots.dump()
|
|
4118
|
+
const ret = { cpp: cppSlots.dump(), compile: compileSlots.dump() };
|
|
4253
4119
|
if (debug) {
|
|
4254
4120
|
console.log("sending dump", ret);
|
|
4255
4121
|
}
|
|
4256
4122
|
compile.send(ret);
|
|
4257
4123
|
});
|
|
4258
|
-
compile.on("subscribeSlots", () => {
|
|
4259
|
-
if (debug) {
|
|
4260
|
-
console.log("subscribeSlots from", compile.id);
|
|
4261
|
-
}
|
|
4262
|
-
const subscriber = {
|
|
4263
|
-
compile,
|
|
4264
|
-
handler: () => {
|
|
4265
|
-
// Remove subscriber on disconnect
|
|
4266
|
-
const idx = slotSubscribers.indexOf(subscriber);
|
|
4267
|
-
if (idx !== -1) {
|
|
4268
|
-
slotSubscribers.splice(idx, 1);
|
|
4269
|
-
}
|
|
4270
|
-
}
|
|
4271
|
-
};
|
|
4272
|
-
slotSubscribers.push(subscriber);
|
|
4273
|
-
compile.on("end", subscriber.handler);
|
|
4274
|
-
compile.on("error", subscriber.handler);
|
|
4275
|
-
// Send current state immediately
|
|
4276
|
-
compile.send(slotsInfo());
|
|
4277
|
-
});
|
|
4278
4124
|
let requestedCppSlot = false;
|
|
4279
|
-
let requestedLocalSlot = false;
|
|
4280
4125
|
compile.on("acquireCppSlot", () => {
|
|
4281
4126
|
if (debug) {
|
|
4282
4127
|
console.log("acquireCppSlot");
|
|
@@ -4320,38 +4165,6 @@ server.on("compile", (compile) => {
|
|
|
4320
4165
|
compileSlots.release(compile.id);
|
|
4321
4166
|
}
|
|
4322
4167
|
});
|
|
4323
|
-
compile.on("acquireSlot", () => {
|
|
4324
|
-
if (debug) {
|
|
4325
|
-
console.log("acquireSlot");
|
|
4326
|
-
}
|
|
4327
|
-
if (canAcquireLocalSlot() && localSlots.tryAcquire(compile.id, { pid: compile.pid })) {
|
|
4328
|
-
if (debug) {
|
|
4329
|
-
console.log("acquireSlot -> local slot granted");
|
|
4330
|
-
}
|
|
4331
|
-
requestedLocalSlot = true;
|
|
4332
|
-
compile.send(Constants.LocalSlotAcquired);
|
|
4333
|
-
}
|
|
4334
|
-
else {
|
|
4335
|
-
if (debug) {
|
|
4336
|
-
console.log("acquireSlot -> falling back to cpp slot");
|
|
4337
|
-
}
|
|
4338
|
-
assert__default["default"](!requestedCppSlot);
|
|
4339
|
-
requestedCppSlot = true;
|
|
4340
|
-
cppSlots.acquire(compile.id, { pid: compile.pid }, () => {
|
|
4341
|
-
compile.send(Constants.CppSlotAcquired);
|
|
4342
|
-
});
|
|
4343
|
-
}
|
|
4344
|
-
});
|
|
4345
|
-
compile.on("releaseLocalSlot", () => {
|
|
4346
|
-
if (debug) {
|
|
4347
|
-
console.log("releaseLocalSlot");
|
|
4348
|
-
}
|
|
4349
|
-
assert__default["default"](requestedLocalSlot);
|
|
4350
|
-
if (requestedLocalSlot) {
|
|
4351
|
-
requestedLocalSlot = false;
|
|
4352
|
-
localSlots.release(compile.id);
|
|
4353
|
-
}
|
|
4354
|
-
});
|
|
4355
4168
|
compile.on("error", (err) => {
|
|
4356
4169
|
if (debug) {
|
|
4357
4170
|
console.error("Got error from fiskc", compile.id, compile.pid, err);
|
|
@@ -4364,10 +4177,6 @@ server.on("compile", (compile) => {
|
|
|
4364
4177
|
requestedCompileSlot = false;
|
|
4365
4178
|
compileSlots.release(compile.id);
|
|
4366
4179
|
}
|
|
4367
|
-
if (requestedLocalSlot) {
|
|
4368
|
-
requestedLocalSlot = false;
|
|
4369
|
-
localSlots.release(compile.id);
|
|
4370
|
-
}
|
|
4371
4180
|
});
|
|
4372
4181
|
compile.on("end", () => {
|
|
4373
4182
|
if (debug) {
|
|
@@ -4381,10 +4190,6 @@ server.on("compile", (compile) => {
|
|
|
4381
4190
|
requestedCompileSlot = false;
|
|
4382
4191
|
compileSlots.release(compile.id);
|
|
4383
4192
|
}
|
|
4384
|
-
if (requestedLocalSlot) {
|
|
4385
|
-
requestedLocalSlot = false;
|
|
4386
|
-
localSlots.release(compile.id);
|
|
4387
|
-
}
|
|
4388
4193
|
});
|
|
4389
4194
|
});
|
|
4390
4195
|
process.on("exit", () => {
|