From 6589671f029d2db3bc110ca0098ed4509c698313 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Fri, 7 May 2021 23:01:11 +0300 Subject: jobd: support 'name' config option --- src/lib/config.js | 1 + src/lib/workers-list.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/config.js b/src/lib/config.js index f3a9e61..4228621 100644 --- a/src/lib/config.js +++ b/src/lib/config.js @@ -71,6 +71,7 @@ function parseWorkerConfig(file) { const raw = readFile(file) const scheme = { + name: {}, host: {required: true}, port: {required: true, type: 'int'}, password: {}, diff --git a/src/lib/workers-list.js b/src/lib/workers-list.js index 3f2246e..c779ec2 100644 --- a/src/lib/workers-list.js +++ b/src/lib/workers-list.js @@ -35,11 +35,12 @@ class WorkersList { /** * @param {Connection} connection * @param {string[]} targets + * @param {string} name */ - add(connection, targets) { - this.logger.info(`add: connection from ${connection.remoteAddr()}, targets ${JSON.stringify(targets)}`) + add(connection, {targets, name}) { + this.logger.info(`add: connection from ${connection.remoteAddr()}, name ${name}, targets ${JSON.stringify(targets)}`) - this.workers.push({connection, targets}) + this.workers.push({connection, targets, name}) connection.on('close', () => { this.logger.info(`connection from ${connection.remoteAddr()} closed, removing worker`) this.workers = this.workers.filter(worker => { @@ -161,7 +162,8 @@ class WorkersList { const workerInfo = { remoteAddr: worker.connection.socket?.remoteAddress, remotePort: worker.connection.socket?.remotePort, - targets: worker.targets + targets: worker.targets, + name: worker.name, } if (pollWorkers) { -- cgit v1.2.3