dcp-worker 3.2.30-2 → 3.2.30-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-worker +116 -85
- package/docs/CODEOWNERS +2 -0
- package/etc/dcp-worker-config.js +1 -1
- package/etc/dcp-worker-config.js.md5 +1 -1
- package/lib/blessed-components/index.js +1 -0
- package/lib/blessed-components/log.js +1 -0
- package/lib/blessed-components/sandboxes.js +10 -6
- package/lib/check-scheduler-version.js +1 -0
- package/lib/dashboard-tui.js +190 -0
- package/lib/default-ui-events.js +172 -0
- package/lib/pidfile.js +1 -1
- package/lib/remote-console.js +10 -2
- package/lib/startWorkerLogger.js +96 -63
- package/lib/utils.js +28 -0
- package/lib/worker-loggers/console.js +24 -108
- package/lib/worker-loggers/dashboard.js +32 -173
- package/lib/worker-loggers/event-log.js +28 -60
- package/lib/worker-loggers/logfile.js +57 -83
- package/lib/worker-loggers/syslog.js +41 -63
- package/package.json +12 -3
- package/lib/worker-loggers/common-types.js +0 -24
|
@@ -4,66 +4,45 @@
|
|
|
4
4
|
* @date August 2022
|
|
5
5
|
*
|
|
6
6
|
* This logger module emits log lines to a remote syslogd, writing all
|
|
7
|
-
* console logs to it.
|
|
8
|
-
* by the console logger.
|
|
9
|
-
*
|
|
10
|
-
* @TODO: This could likely be improved by handling worker events directly
|
|
11
|
-
* and emitting events to the event log more deliberately than just
|
|
12
|
-
* redirecting the base console output. ~ER20220831
|
|
7
|
+
* console logs to it.
|
|
13
8
|
*/
|
|
9
|
+
'use strict';
|
|
14
10
|
|
|
15
|
-
require('
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const syslog = require('syslog-client');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
const syslog = require('syslog-client');
|
|
13
|
+
const process = require('process');
|
|
19
14
|
|
|
20
15
|
// Copy the original global console object's properties onto a backup
|
|
21
16
|
const _console = Object.assign({}, console);
|
|
17
|
+
var syslogClient;
|
|
18
|
+
var processName;
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
init(worker, options) {
|
|
33
|
-
consoleLogger.init(worker, options);
|
|
34
|
-
|
|
35
|
-
this.options = Object.assign({}, options);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the syslog worker logger
|
|
22
|
+
*
|
|
23
|
+
* @param {object} cliArgs Options for logger behaviour (passed
|
|
24
|
+
* through to consoleLogger)
|
|
25
|
+
*/
|
|
26
|
+
exports.init = function syslog$$init(cliArgs)
|
|
27
|
+
{
|
|
28
|
+
{
|
|
36
29
|
const syslogOptions = {
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
syslogHostname: os.hostname(),
|
|
31
|
+
transport: cliArgs.syslogTransport || 'udp', // tcp, udp, unix, tls
|
|
32
|
+
port: cliArgs.syslogPort,
|
|
33
|
+
facility: syslog.Facility[cliArgs.syslogFacility[0].toUpperCase() + cliArgs.syslogFacility.slice(1)],
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
},
|
|
36
|
+
syslogClient = syslog.createClient(cliArgs.syslogAddress || '127.0.0.1', syslogOptions);
|
|
37
|
+
processName = require('path').basename(process.mainModule.filename || process.argv0);
|
|
38
|
+
exports.close = () => syslogClient.close();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
switch (typeof i) {
|
|
55
|
-
case 'object':
|
|
56
|
-
strBuilder.push(JSON.stringify(i));
|
|
57
|
-
default:
|
|
58
|
-
strBuilder.push(String(i));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
if (e instanceof TypeError) {
|
|
63
|
-
strBuilder.push('[encoding error: ' + e.message + ']');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
42
|
+
function log(level, ...argv)
|
|
43
|
+
{
|
|
44
|
+
{
|
|
45
|
+
const logPrefix = `${processName}[${process.pid}]: `;
|
|
67
46
|
|
|
68
47
|
// Use the string log-level to look up the severity number:
|
|
69
48
|
let severity = {
|
|
@@ -74,18 +53,17 @@ const eventlogLogger = {
|
|
|
74
53
|
debug: syslog.Severity.Debug,
|
|
75
54
|
}[level];
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
severity,
|
|
79
|
-
}, error => {
|
|
80
|
-
if (error)
|
|
81
|
-
_console.error('168: Unexpected error writing to syslog:', error);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
};
|
|
56
|
+
const logMessages = argv.join(' ').split('\n');
|
|
85
57
|
|
|
86
|
-
for (
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
58
|
+
for (let logMessage of logMessages)
|
|
59
|
+
{
|
|
60
|
+
logMessage = logPrefix + logMessage;
|
|
61
|
+
syslogClient.log(logMessage, { severity }, error => {
|
|
62
|
+
if (error)
|
|
63
|
+
_console.error('168: Unexpected error writing to syslog:');
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
90
67
|
}
|
|
91
|
-
|
|
68
|
+
|
|
69
|
+
exports.at = log;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcp-worker",
|
|
3
|
-
"version": "3.2.30-
|
|
3
|
+
"version": "3.2.30-4",
|
|
4
4
|
"description": "JavaScript portion of DCP Workers for Node.js",
|
|
5
5
|
"main": "bin/dcp-worker",
|
|
6
6
|
"keywords": [
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
"blessed": "^0.1.81",
|
|
38
38
|
"blessed-contrib": "^4.11.0",
|
|
39
39
|
"chalk": "^4.1.0",
|
|
40
|
-
"dcp-client": "
|
|
41
|
-
"semver": "^7.3.8"
|
|
40
|
+
"dcp-client": "gitlab:Distributed-Compute-Protocol/dcp-client#develop",
|
|
41
|
+
"semver": "^7.3.8",
|
|
42
|
+
"syslog-client": "1.1.1"
|
|
42
43
|
},
|
|
43
44
|
"optionalDependencies": {
|
|
44
45
|
"telnet-console": "^1.0.4"
|
|
@@ -47,6 +48,14 @@
|
|
|
47
48
|
"@kingsds/eslint-config": "^1.0.1",
|
|
48
49
|
"eslint": "7.30.0"
|
|
49
50
|
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"node-eventlog": "https://gitpkg.now.sh/Distributive-Network/node-eventlog/package?dcp/0.0.1"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"node-eventlog": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
50
59
|
"engines": {
|
|
51
60
|
"node": ">=16",
|
|
52
61
|
"npm": ">=7"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef WorkerLogger
|
|
3
|
-
* @property {onSandboxReady} onSandboxReady
|
|
4
|
-
* @property {function} onPayment
|
|
5
|
-
* @property {function} onFetchingSlices
|
|
6
|
-
* @property {function} onFetchedSlices
|
|
7
|
-
* @property {function} onFetchSlicesFailed
|
|
8
|
-
* @property {SandboxCallback} sandbox$onSliceStart
|
|
9
|
-
* @property {SandboxCallback} sandbox$onSliceProgress
|
|
10
|
-
* @property {SandboxCallback} sandbox$onSliceFinish
|
|
11
|
-
* @property {SandboxCallback} sandbox$onWorkerStop
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {function} onSandboxReady
|
|
16
|
-
* @param {Sandbox} sandbox
|
|
17
|
-
* @returns {object} workerData
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {function} SandboxCallback
|
|
22
|
-
* @param {Sandbox} sandbox
|
|
23
|
-
* @param {object} workerData
|
|
24
|
-
*/
|