dcp-worker 4.2.3 → 4.2.4
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/bin/dcp-evaluator-manager +30 -18
- package/package.json +2 -2
|
@@ -38,15 +38,16 @@ var seq = 0;
|
|
|
38
38
|
var ptsDir = '/dev/pts';
|
|
39
39
|
var lastConnectionMs = 0;
|
|
40
40
|
|
|
41
|
+
const defaultSocketDisplayLimit = Number(process.env.DCP_EM_RAW_BYTES || '93');
|
|
41
42
|
const defaultPrefix = '/usr';
|
|
42
43
|
const daemonConfig = {
|
|
43
44
|
net: new URL('tcpip://localhost:9000/'),
|
|
44
45
|
proc: process.argv[0],
|
|
45
|
-
argv: [ require.resolve('./dcp-evaluator-start'), '-s',
|
|
46
|
-
pidfile: pidfile.
|
|
46
|
+
argv: [ require.resolve('./dcp-evaluator-start'), '-s', `--prefix=${path.resolve(defaultPrefix)}/` ],
|
|
47
|
+
pidfile: pidfile.getDefaultPidFileName(),
|
|
47
48
|
limits: {
|
|
48
49
|
loadavgType: 'short',
|
|
49
|
-
|
|
50
|
+
maxLoad: Math.max(2, os.cpus().length * 2),
|
|
50
51
|
},
|
|
51
52
|
session: {
|
|
52
53
|
idlePoll: 3, /* s between checks*/
|
|
@@ -78,24 +79,29 @@ Where:
|
|
|
78
79
|
-p specifies the port to listen on for dcpsaw: worker connections (${daemonConfig.net.port})
|
|
79
80
|
-H specifies the address to listen on for dcpsaw: worker connections (${daemonConfig.net.port})
|
|
80
81
|
--prefix specifies the directory where the DCP evaluator package was installed
|
|
81
|
-
--pidfile specifies an alternate location for the pid file
|
|
82
|
+
--pidfile specifies an alternate location for the pid file;
|
|
83
|
+
currently ${daemonConfig.pidfile}
|
|
82
84
|
--pts specifies the location of the system's pseudo terminal (${ptsDir})
|
|
83
85
|
--disable-monitor=session disables monitoring of ssh/telnet/etc sessions
|
|
84
86
|
--disable-monitor=screensaver disables monitoring of the screensaver
|
|
85
87
|
--disable-monitor=signal disables monitoring of the signal
|
|
86
88
|
--signal=name,mode changes which signal to monitor and its behaviour. Toggle
|
|
87
|
-
mode turns the monitor on/off, quick mode kills active evaluators but
|
|
88
|
-
|
|
89
|
-
-a means always run the evaluator, even
|
|
89
|
+
mode turns the monitor on/off, quick mode kills active evaluators but more
|
|
90
|
+
can spawn right away. Currently ${daemonConfig.signal.which},${daemonConfig.signal.mode}.
|
|
91
|
+
-a means always run the evaluator, even if the monitors say the machine is busy
|
|
90
92
|
--rate specifies the minimum number of seconds between connections
|
|
91
|
-
--max-load specifies the point at which machine load prevents connections
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
--max-load specifies the point at which machine load prevents connections.
|
|
94
|
+
A value of zero disables this limit; the default value is ${daemonConfig.limits.maxLoad}.
|
|
95
|
+
--loadavg-type determines how load is measured; 'short', 'medium', 'long',
|
|
96
|
+
'random'. Random generates a load between 0 and 1 (${daemonConfig.limits.loadavgType}).
|
|
97
|
+
|
|
94
98
|
-L only apply the limits when the monitors say the machine is busy
|
|
95
99
|
|
|
96
100
|
Environment:
|
|
97
|
-
DEBUG
|
|
98
|
-
|
|
101
|
+
DEBUG - enables debugging, eg
|
|
102
|
+
DEBUG='dcp-evaluator-*,-dcp-evaluator-manager:network'
|
|
103
|
+
DCP_CONFIG - sets location of dcp-worker-config file
|
|
104
|
+
DCP_EM_RAW_BYTES - number of bytes to display in :network debugging
|
|
99
105
|
`);
|
|
100
106
|
|
|
101
107
|
process.exit(0);
|
|
@@ -194,15 +200,18 @@ function handleConnection (socket, config)
|
|
|
194
200
|
|
|
195
201
|
switch(daemonConfig.limits.loadavgType)
|
|
196
202
|
{
|
|
203
|
+
default:
|
|
204
|
+
console.warn(`Warning: invalid loadavg type ${daemonConfig.limits.loadavgType}`);
|
|
205
|
+
/* fallthrough */
|
|
197
206
|
case 'short':
|
|
198
|
-
loadavg = os.loadavg[0];
|
|
207
|
+
loadavg = os.loadavg()[0];
|
|
199
208
|
break;
|
|
200
209
|
case 'medium':
|
|
201
210
|
case 'med':
|
|
202
|
-
loadavg = os.loadavg[1];
|
|
211
|
+
loadavg = os.loadavg()[1];
|
|
203
212
|
break;
|
|
204
213
|
case 'long':
|
|
205
|
-
loadavg = os.loadavg[2];
|
|
214
|
+
loadavg = os.loadavg()[2];
|
|
206
215
|
break;
|
|
207
216
|
case 'random': /* random number in range [0,1) that usually changes slowly and averages 0.5 */
|
|
208
217
|
{
|
|
@@ -214,7 +223,7 @@ function handleConnection (socket, config)
|
|
|
214
223
|
}
|
|
215
224
|
}
|
|
216
225
|
|
|
217
|
-
if (daemonConfig.limits.maxLoad < loadavg)
|
|
226
|
+
if (daemonConfig.limits.maxLoad && daemonConfig.limits.maxLoad < loadavg)
|
|
218
227
|
{
|
|
219
228
|
debug('dcp-evaluator-manager')(`New connection; closing due to ${daemonConfig.limits.loadavgType} system load ${loadavg} (${os.loadavg().join(', ')})`);
|
|
220
229
|
cleanup();
|
|
@@ -267,7 +276,7 @@ function handleConnection (socket, config)
|
|
|
267
276
|
});
|
|
268
277
|
|
|
269
278
|
child.stdout.on('data', function (data) {
|
|
270
|
-
debug('dcp-evaluator-manager:network')('<', child.id, bufToDisplayStr(data)
|
|
279
|
+
debug('dcp-evaluator-manager:network')('<', child.id, bufToDisplayStr(data));
|
|
271
280
|
if (socket)
|
|
272
281
|
socket.write(data);
|
|
273
282
|
});
|
|
@@ -277,7 +286,7 @@ function handleConnection (socket, config)
|
|
|
277
286
|
});
|
|
278
287
|
|
|
279
288
|
socket.on('data', function (data) {
|
|
280
|
-
debug('dcp-evaluator-manager:network')('>', child.id, bufToDisplayStr(data
|
|
289
|
+
debug('dcp-evaluator-manager:network')('>', child.id, bufToDisplayStr(data));
|
|
281
290
|
|
|
282
291
|
try
|
|
283
292
|
{
|
|
@@ -297,6 +306,8 @@ function handleConnection (socket, config)
|
|
|
297
306
|
function bufToDisplayStr (buf, limit)
|
|
298
307
|
{
|
|
299
308
|
const str = buf.toString('utf-8').replace(/\n/, '\u2424').toString('utf-8');
|
|
309
|
+
if (typeof limit === 'undefined')
|
|
310
|
+
limit = defaultSocketDisplayLimit;
|
|
300
311
|
|
|
301
312
|
if (typeof limit === 'number' && str.length > limit)
|
|
302
313
|
return str.substr(0, limit) + '\u2026';
|
|
@@ -589,6 +600,7 @@ async function main()
|
|
|
589
600
|
case 'R':
|
|
590
601
|
{
|
|
591
602
|
daemonConfig.limits.randomLoad = true;
|
|
603
|
+
daemonConfig.limits.randomLoadSamples = new Array(5).fill(0.5);
|
|
592
604
|
break;
|
|
593
605
|
}
|
|
594
606
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcp-worker",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.4",
|
|
4
4
|
"description": "Node.js Worker for Distributive Compute Platform",
|
|
5
5
|
"main": "bin/dcp-worker",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"blessed": "0.1.81",
|
|
40
40
|
"blessed-contrib": "4.11.0",
|
|
41
41
|
"chalk": "^4.1.0",
|
|
42
|
-
"dcp-client": "^5.1.
|
|
42
|
+
"dcp-client": "^5.1.5",
|
|
43
43
|
"kvin": "^1.2.7",
|
|
44
44
|
"posix-getopt": "^1.2.1",
|
|
45
45
|
"semver": "^7.3.8",
|