From 50e575e764c141b6cb47f267a53404297629d3a8 Mon Sep 17 00:00:00 2001 From: CombatPug Date: Fri, 11 Oct 2024 11:37:19 +0200 Subject: [PATCH 1/3] feat: determine clean or unclean exit depending on current node status --- src/exit-handler/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/exit-handler/index.ts b/src/exit-handler/index.ts index 3463c89b4..c8ae8689a 100644 --- a/src/exit-handler/index.ts +++ b/src/exit-handler/index.ts @@ -241,8 +241,12 @@ class ExitHandler { addSigListeners(sigint = true, sigterm = true) { if (sigint) { process.on('SIGINT', async () => { - // await this.exitCleanly() - await this.exitUncleanly('SIGINT', 'Process exited with SIGINT') + const nodeInfo = Self.getPublicNodeInfo(true) + if (nodeInfo.status === 'standby' || nodeInfo.status === 'initializing' || nodeInfo.status === 'ready') { + await this.exitCleanly('SIGINT', 'Process exited with SIGINT') + } else { + await this.exitUncleanly('SIGINT', 'Process exited with SIGINT') + } }) //gracefull shutdown suppport in windows. should mirror what SIGINT does in linux process.on('message', async (msg) => { From ca03167e61b2aae4a473ab92c745c9f6874db3cb Mon Sep 17 00:00:00 2001 From: CombatPug Date: Fri, 11 Oct 2024 12:14:34 +0200 Subject: [PATCH 2/3] add more info to unclean message for SIGINT --- src/exit-handler/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exit-handler/index.ts b/src/exit-handler/index.ts index c8ae8689a..49079c461 100644 --- a/src/exit-handler/index.ts +++ b/src/exit-handler/index.ts @@ -245,7 +245,7 @@ class ExitHandler { if (nodeInfo.status === 'standby' || nodeInfo.status === 'initializing' || nodeInfo.status === 'ready') { await this.exitCleanly('SIGINT', 'Process exited with SIGINT') } else { - await this.exitUncleanly('SIGINT', 'Process exited with SIGINT') + await this.exitUncleanly('SIGINT', 'Process exited with SIGINT while active') } }) //gracefull shutdown suppport in windows. should mirror what SIGINT does in linux From e4b725dc576bc8f925c57c61178cadb1e119a758 Mon Sep 17 00:00:00 2001 From: CombatPug Date: Fri, 11 Oct 2024 12:28:59 +0200 Subject: [PATCH 3/3] formatting --- src/exit-handler/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/exit-handler/index.ts b/src/exit-handler/index.ts index 49079c461..ec21d61a1 100644 --- a/src/exit-handler/index.ts +++ b/src/exit-handler/index.ts @@ -241,8 +241,12 @@ class ExitHandler { addSigListeners(sigint = true, sigterm = true) { if (sigint) { process.on('SIGINT', async () => { - const nodeInfo = Self.getPublicNodeInfo(true) - if (nodeInfo.status === 'standby' || nodeInfo.status === 'initializing' || nodeInfo.status === 'ready') { + const nodeInfo = getPublicNodeInfo(true) + if ( + nodeInfo.status === 'standby' || + nodeInfo.status === 'initializing' || + nodeInfo.status === 'ready' + ) { await this.exitCleanly('SIGINT', 'Process exited with SIGINT') } else { await this.exitUncleanly('SIGINT', 'Process exited with SIGINT while active')