From 46d0cf9c4b5889c3d6c3ef638bd7ca84c72d947c Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 4 Jul 2019 15:17:14 +0100 Subject: [PATCH] increased logging info (#27) --- services/spelling/app/js/ASpellWorker.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/services/spelling/app/js/ASpellWorker.js b/services/spelling/app/js/ASpellWorker.js index 4f91eb54e4..07abb492ab 100644 --- a/services/spelling/app/js/ASpellWorker.js +++ b/services/spelling/app/js/ASpellWorker.js @@ -19,6 +19,7 @@ class ASpellWorker { constructor(language) { this.language = language this.count = 0 + this.closeReason = '' this.pipe = childProcess.spawn('aspell', [ 'pipe', '-t', @@ -43,19 +44,29 @@ class ASpellWorker { }) }) this.pipe.on('close', () => { + const previousWorkerState = this.state if (this.state !== 'killed') { this.state = 'closed' } if (this.callback != null) { const err = new errorType.Error({ message: 'aspell worker closed output streams with uncalled callback', - info: { process: this.pipe.pid, lang: this.language } + info: { + process: this.pipe.pid, + lang: this.language, + stdout: output.slice(-1024), + stderr: error.slice(-1024), + workerState: this.state, + previousWorkerState, + closeReason: this.closeReason + } }) this.callback(err, []) this.callback = null } }) this.pipe.on('error', err => { + const previousWorkerState = this.state if (this.state !== 'killed') { this.state = 'error' } @@ -64,7 +75,9 @@ class ASpellWorker { stdout: output.slice(-1024), stderr: error.slice(-1024), lang: this.language, - workerState: this.state + workerState: this.state, + previousWorkerState, + closeReason: this.closeReason } if (this.callback != null) { @@ -81,6 +94,7 @@ class ASpellWorker { } }) this.pipe.stdin.on('error', err => { + const previousWorkerState = this.state if (this.state !== 'killed') { this.state = 'error' } @@ -89,7 +103,9 @@ class ASpellWorker { stdout: output.slice(-1024), stderr: error.slice(-1024), lang: this.language, - workerState: this.state + workerState: this.state, + previousWorkerState, + closeReason: this.closeReason } if (this.callback != null) { @@ -199,11 +215,13 @@ class ASpellWorker { shutdown(reason) { logger.info({ process: this.pipe.pid, reason }, 'shutting down') this.state = 'closing' + this.closeReason = reason return this.pipe.stdin.end() } kill(reason) { logger.info({ process: this.pipe.pid, reason }, 'killing') + this.closeReason = reason if (this.state === 'killed') { return }