diff --git a/.origintrail_noderc.travis b/.origintrail_noderc.travis index 47ed20d247..416fc32ddd 100644 --- a/.origintrail_noderc.travis +++ b/.origintrail_noderc.travis @@ -3,5 +3,6 @@ "node_private_key": "askRadomirIfYouNeedIt", "database": { "password": "root" - } + }, + "commandExecutorVerboseLoggingEnabled": true } diff --git a/config/config.json b/config/config.json index aba3d1debd..0ccac19e4f 100644 --- a/config/config.json +++ b/config/config.json @@ -96,7 +96,8 @@ "deposit_on_demand": true, "dc_choose_time": 600000, "requireApproval": false, - "litigationEnabled": true + "litigationEnabled": true, + "commandExecutorVerboseLoggingEnabled": false }, "staging": { "identity": null, @@ -195,7 +196,8 @@ "deposit_on_demand": false, "dc_choose_time": 600000, "requireApproval": false, - "litigationEnabled": true + "litigationEnabled": true, + "commandExecutorVerboseLoggingEnabled": false }, "stable": { "identity": null, @@ -294,7 +296,8 @@ "deposit_on_demand": false, "dc_choose_time": 600000, "requireApproval": false, - "litigationEnabled": true + "litigationEnabled": true, + "commandExecutorVerboseLoggingEnabled": false }, "production": { "identity": null, @@ -396,7 +399,8 @@ "deposit_on_demand": false, "dc_choose_time": 600000, "requireApproval": false, - "litigationEnabled": true + "litigationEnabled": true, + "commandExecutorVerboseLoggingEnabled": false }, "mariner": { "identity": null, @@ -498,6 +502,7 @@ "deposit_on_demand": false, "dc_choose_time": 600000, "requireApproval": true, - "litigationEnabled": false + "litigationEnabled": false, + "commandExecutorVerboseLoggingEnabled": false } } diff --git a/modules/command/command-executor.js b/modules/command/command-executor.js index 30ef9b38e8..586cbec35a 100644 --- a/modules/command/command-executor.js +++ b/modules/command/command-executor.js @@ -37,12 +37,16 @@ class CommandExecutor { this.started = false; this.parallelism = QUEUE_PARALLELISM; + this.verboseLoggingEnabled = ctx.config.commandExecutorVerboseLoggingEnabled; const that = this; this.queue = async.queue(async (command, callback) => { try { while (!that.started) { - that.logger.trace('Command executor has not been started yet. Hibernating...'); + if (that.verboseLoggingEnabled) { + that.logger.trace('Command executor has not been started yet. Hibernating...'); + } + // eslint-disable-next-line await sleep.sleep(1000); } @@ -66,7 +70,9 @@ class CommandExecutor { constants.PERMANENT_COMMANDS, async command => this._startDefaultCommand(command), ); - this.logger.trace('Command executor has been initialized...'); + if (this.verboseLoggingEnabled) { + this.logger.trace('Command executor has been initialized...'); + } } /** @@ -75,7 +81,9 @@ class CommandExecutor { */ async start() { this.started = true; - this.logger.trace('Command executor has been started...'); + if (this.verboseLoggingEnabled) { + this.logger.trace('Command executor has been started...'); + } } /** @@ -88,7 +96,9 @@ class CommandExecutor { started_at: now, }); - this.logger.trace(`Command ${command.name} and ID ${command.id} started.`); + if (this.verboseLoggingEnabled) { + this.logger.trace(`Command ${command.name} and ID ${command.id} started.`); + } const handler = this.commandResolver.resolve(command.name); if (command.deadline_at && now > command.deadline_at) { @@ -110,7 +120,9 @@ class CommandExecutor { const waitMs = (command.ready_at + command.delay) - now; if (waitMs > 0) { - this.logger.trace(`Command ${command.name} with ID ${command.id} should be delayed`); + if (this.verboseLoggingEnabled) { + this.logger.trace(`Command ${command.name} with ID ${command.id} should be delayed`); + } await this.add(command, Math.min(waitMs, constants.MAX_COMMAND_DELAY_IN_MILLS), false); return; } @@ -151,7 +163,9 @@ class CommandExecutor { }, command.transactional); if (!result.repeat) { - this.logger.trace(`Command ${command.name} and ID ${command.id} processed.`); + if (this.verboseLoggingEnabled) { + this.logger.trace(`Command ${command.name} and ID ${command.id} processed.`); + } result.children.forEach(async e => this.add(e, e.delay, false)); } } catch (e) { @@ -193,7 +207,9 @@ class CommandExecutor { await CommandExecutor._delete(name); const handler = this.commandResolver.resolve(name); await this.add(handler.default(), 0, true); - this.logger.trace(`Permanent command ${name} created.`); + if (this.verboseLoggingEnabled) { + this.logger.trace(`Permanent command ${name} created.`); + } } /** diff --git a/package-lock.json b/package-lock.json index 17634addbb..2c6cd03da4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index aea403a989..0f7a8605bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "3.0.1", + "version": "3.0.2", "description": "OriginTrail node", "main": ".eslintrc.js", "config": { diff --git a/test/modules/utilities.test.js b/test/modules/utilities.test.js index 8318559997..e47af87b93 100644 --- a/test/modules/utilities.test.js +++ b/test/modules/utilities.test.js @@ -27,7 +27,7 @@ describe('Utilities module', () => { 'is_bootstrap_node', 'houston_password', 'enable_debug_logs_level', 'reverse_tunnel_address', 'reverse_tunnel_port', 'autoUpdater', 'bugSnag', 'network', 'dataSetStorage', 'dc_holding_time_in_minutes', 'dc_choose_time', 'dc_litigation_interval_in_minutes', 'dc_token_amount_per_holder', 'dh_max_holding_time_in_minutes', 'dh_min_litigation_interval_in_minutes', 'dh_min_token_price', - 'erc725_identity_filepath', 'deposit_on_demand', 'requireApproval', 'litigationEnabled'], + 'erc725_identity_filepath', 'deposit_on_demand', 'requireApproval', 'litigationEnabled', 'commandExecutorVerboseLoggingEnabled'], `Some config items are missing in config for environment '${environment}'`, ); assert.hasAllKeys(