From 66438808ec929978edba3a015490159a6c0f9f55 Mon Sep 17 00:00:00 2001 From: Luca Pradovera Date: Thu, 19 Nov 2020 21:28:04 +0100 Subject: [PATCH 1/2] First pass at ignoring signals --- packages/node/src/relay/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/node/src/relay/index.ts b/packages/node/src/relay/index.ts index 74ec026c..6b116e3b 100644 --- a/packages/node/src/relay/index.ts +++ b/packages/node/src/relay/index.ts @@ -40,8 +40,12 @@ export default class RelayClient extends BaseSession { private _handleSignals(): void { const _gracefulDisconnect = async () => { - logger.info('Disconnecting from Relay...') - await this.disconnect() + if (process.env.IGNORE_SIGNALS) { + logger.info('Ignoring SIGINT/SIGTERM as requested.') + } else { + logger.info('Disconnecting from Relay...') + await this.disconnect() + } } process.on('SIGTERM', _gracefulDisconnect) From 24fa38288b81b9cca2aef88c0461658405a46451 Mon Sep 17 00:00:00 2001 From: Edoardo Gallo Date: Thu, 19 Nov 2020 23:14:00 +0100 Subject: [PATCH 2/2] do not attach signals listeners if IGNORE_SIGNALS is set --- packages/node/src/relay/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/node/src/relay/index.ts b/packages/node/src/relay/index.ts index 6b116e3b..4913794e 100644 --- a/packages/node/src/relay/index.ts +++ b/packages/node/src/relay/index.ts @@ -39,13 +39,13 @@ export default class RelayClient extends BaseSession { } private _handleSignals(): void { + if (process.env.IGNORE_SIGNALS) { + return logger.info('Ignoring SIGINT/SIGTERM as requested.') + } + const _gracefulDisconnect = async () => { - if (process.env.IGNORE_SIGNALS) { - logger.info('Ignoring SIGINT/SIGTERM as requested.') - } else { - logger.info('Disconnecting from Relay...') - await this.disconnect() - } + logger.info('Disconnecting from Relay...') + await this.disconnect() } process.on('SIGTERM', _gracefulDisconnect)