dcp-worker 4.2.7 → 4.3.1

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 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. Note that only one type of output at a
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.
@@ -128,6 +128,13 @@ async function listenForConnections(config)
128
128
 
129
129
  server.listen({ host: hostaddr, port: config.net.port }, function daemonReady() {
130
130
  console.log('Listening for connections on', server._connectionKey);
131
+ if (Number(config.net.port) === 0)
132
+ {
133
+ console.log('Using dynamic port', server.address().port);
134
+ // Send info by IPC, if the spawn is setup for that. Probably don't need to try/catch.
135
+ if (process.send)
136
+ try { process.send(server.address().port); } catch (e) {}
137
+ }
131
138
  console.log('Evaluator command is', config.proc, config.argv);
132
139
  });
133
140
  }
@@ -538,7 +545,7 @@ function odRequire(moduleId)
538
545
  async function main()
539
546
  {
540
547
  const parser = new getopt.BasicParser('h(help)P:(prefix)H:p:d:(disable-monitor)l:(max-load)r:(rate)'
541
- + 'Li:as:(signal)T:(loadavg-type)f:(pidfile)', process.argv);
548
+ + 'Li:as:(signal)T:(loadavg-type)f:(pidfile)n(no-pidfile)', process.argv);
542
549
  var option;
543
550
 
544
551
  if (dcpConfig.evaluator.listen)
@@ -651,6 +658,13 @@ async function main()
651
658
  case 'f':
652
659
  {
653
660
  daemonConfig.pidfile = option.optarg;
661
+ break;
662
+ }
663
+
664
+ case 'n':
665
+ {
666
+ daemonConfig.pidfile = false;
667
+ break;
654
668
  }
655
669
  }
656
670
  }
package/bin/dcp-worker CHANGED
@@ -53,7 +53,8 @@ const replHelpers = {
53
53
  },
54
54
  };
55
55
  telnetd.init(replHelpers);
56
- require('dcp-client').init().then(main).catch(handleUnhandled);
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 URL pathname.
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 || new URL('udp://localhost:514/local7'),
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 = {
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 and no other components
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.2.7",
3
+ "version": "4.3.1",
4
4
  "description": "Node.js Worker for Distributive Compute Platform",
5
5
  "main": "bin/dcp-worker",
6
6
  "keywords": [
@@ -39,12 +39,12 @@
39
39
  "blessed": "0.1.81",
40
40
  "blessed-contrib": "4.11.0",
41
41
  "chalk": "^4.1.0",
42
- "dcp-client": "5.1.9",
43
- "kvin": "^1.2.7",
42
+ "dcp-client": "^5.2.0",
43
+ "kvin": "^9.0.0",
44
44
  "posix-getopt": "^1.2.1",
45
45
  "semver": "^7.3.8",
46
46
  "syslog-client": "1.1.1",
47
- "syslog-client-tls": "1.2.1",
47
+ "syslog-client-tls": "github:wesgarland/node-syslog-client#0d734f33767bc6a8275552d3daa51712cc2d306d",
48
48
  "websocket": "1.0.34"
49
49
  },
50
50
  "optionalDependencies": {