dcp-worker 4.3.0 → 4.3.2
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/README.md +1 -3
- package/bin/dcp-worker +8 -5
- package/lib/utils.js +1 -1
- package/lib/worker-loggers/syslog.js +16 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -58,9 +58,7 @@ Evaluator in real time. `dcp-worker -h` shows a help screen; to run in interact
|
|
|
58
58
|
|
|
59
59
|
Administrators with a large number of workers may wish to configure [syslog](https://en.wikipedia.org/wiki/Syslog)
|
|
60
60
|
logging, and use an off-the-shelf logging aggregation service. The full gamut of options relating to
|
|
61
|
-
syslog output are documented in the `dcp-worker` help screen.
|
|
62
|
-
time is currently possible with `dcp-worker`; Linux administrators who want both system journals and
|
|
63
|
-
syslog output will need to configure their local syslog service to receive messages from systemd.
|
|
61
|
+
syslog output are documented in the `dcp-worker` help screen.
|
|
64
62
|
|
|
65
63
|
The Worker can log its activities to a variety of destinations (dependent on operating system), and
|
|
66
64
|
emits logs when new jobs are fetched, job slices are completed, and so on.
|
package/bin/dcp-worker
CHANGED
|
@@ -53,7 +53,8 @@ const replHelpers = {
|
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
telnetd.init(replHelpers);
|
|
56
|
-
|
|
56
|
+
const dcpClientOptions = { dcpConfig: { worker: { logging: { syslog: {} } } } };
|
|
57
|
+
require('dcp-client').init(dcpClientOptions).then(main).catch(handleUnhandled);
|
|
57
58
|
|
|
58
59
|
function usage()
|
|
59
60
|
{
|
|
@@ -83,7 +84,8 @@ Options:
|
|
|
83
84
|
--logfile=filename Change filename, implies --logger=logfile
|
|
84
85
|
--overwrite-logfile Overwrite previous log files instead of appending
|
|
85
86
|
--syslog=url Change syslog url, implies --logger=syslog. Syslog
|
|
86
|
-
facility (eg. local7) is the
|
|
87
|
+
facility (eg. local7) is the pathname, structured
|
|
88
|
+
data is encoded in search params; id+name=value.
|
|
87
89
|
--syslog=facility Change syslog facility, implies --logger=syslog.
|
|
88
90
|
--min-level=[logger,]level Set the lowest level of log sent to a given logger
|
|
89
91
|
--min-level=[console,]level Set the lowest level of log sent to the console
|
|
@@ -203,7 +205,7 @@ function processCliOptsPhase1(argv, operatingMode)
|
|
|
203
205
|
const loggingOptions = {
|
|
204
206
|
minLevel: { all: undefined }, /* minimum logging levels for console and per logger */
|
|
205
207
|
loggers: [], /* names of loggers (places logs go besides console) */
|
|
206
|
-
syslogUrl: dcpConfig.worker.logging?.syslog?.url ||
|
|
208
|
+
syslogUrl: new URL(dcpConfig.worker.logging?.syslog?.url || 'udp://localhost:514/local7'),
|
|
207
209
|
logfile: path.resolve(path.dirname(require.main.filename), dcpConfig.worker.logging?.logfile || '../log/dcp-worker.log'),
|
|
208
210
|
};
|
|
209
211
|
const evaluatorOptions = {
|
|
@@ -685,7 +687,8 @@ async function main()
|
|
|
685
687
|
if (!handleWorkerError.count)
|
|
686
688
|
{
|
|
687
689
|
console.error('Unrecoverable', error.code ? `${error.name} (${error.code})` : error.name,
|
|
688
|
-
'- shutting down the worker:',
|
|
690
|
+
'- shutting down the worker:',
|
|
691
|
+
process.env.DCP_SUPERVISOR_DEBUG_DISPLAY_MAX_INFO ? error : error.message);
|
|
689
692
|
}
|
|
690
693
|
|
|
691
694
|
/* Let the supervisor try to finish slices for up to three minutes after a single unrecoverable error. */
|
|
@@ -705,7 +708,7 @@ async function main()
|
|
|
705
708
|
{
|
|
706
709
|
const amount = await DistributiveWorker.checkUnclaimedEarnings();
|
|
707
710
|
if (amount.gt(0))
|
|
708
|
-
console.
|
|
711
|
+
console.info(` ! not claming earnings in the amount of ${amount} ⊇ (can claim later)`);
|
|
709
712
|
}
|
|
710
713
|
|
|
711
714
|
console.info(' * Ready.\n');
|
package/lib/utils.js
CHANGED
|
@@ -114,7 +114,7 @@ function uniq(array)
|
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Syslog URLs are bit special - the pathname of the URL encodes the syslog facility. Additionally, a
|
|
117
|
-
* plain string treated as just a pathname
|
|
117
|
+
* plain string treated as just a pathname.
|
|
118
118
|
*
|
|
119
119
|
* existingUrl newArg result
|
|
120
120
|
* ------------------------------- -------------------------------- ----------------------------------
|
|
@@ -69,6 +69,22 @@ exports.open = function syslog$$open(options)
|
|
|
69
69
|
if (!syslogTarget)
|
|
70
70
|
throw new Error('missing syslog target');
|
|
71
71
|
|
|
72
|
+
if (options.syslogUrl.search)
|
|
73
|
+
{
|
|
74
|
+
/* search encodes RFC5424 structured data of the form ?id+param1=value1&id+param2=value2 into
|
|
75
|
+
* { id: { param1: value1, param2: value2 } } for consumption by the syslog-client-tls package.
|
|
76
|
+
*/
|
|
77
|
+
const elements = {};
|
|
78
|
+
options.syslogUrl.searchParams.forEach((sdValue, name) => {
|
|
79
|
+
const [ sdId, sdParamName ] = name.split(' ');
|
|
80
|
+
if (!elements[sdId])
|
|
81
|
+
elements[sdId] = {};
|
|
82
|
+
elements[sdId][sdParamName] = sdValue;
|
|
83
|
+
});
|
|
84
|
+
syslogOptions.structuredData = elements;
|
|
85
|
+
debug('dcp-worker:logger')(`syslog data includes ${Object.keys(elements).length} structured data elements`);
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
debug('dcp-worker:logger')('connecting to syslogd at ' + options.syslogUrl);
|
|
73
89
|
syslogClient = syslog.createClient(options.syslogUrl.hostname, syslogOptions);
|
|
74
90
|
processName = require('path').basename(process.mainModule.filename) || 'dcp-worker';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcp-worker",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "Node.js Worker for Distributive Compute Platform",
|
|
5
5
|
"main": "bin/dcp-worker",
|
|
6
6
|
"keywords": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"posix-getopt": "^1.2.1",
|
|
45
45
|
"semver": "^7.3.8",
|
|
46
46
|
"syslog-client": "1.1.1",
|
|
47
|
-
"syslog-client-tls": "
|
|
47
|
+
"syslog-client-tls": "github:wesgarland/node-syslog-client#0d734f33767bc6a8275552d3daa51712cc2d306d",
|
|
48
48
|
"websocket": "1.0.34"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|