From 6e18898c9a930ac5cff0ddf1878a632259cd4267 Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 10 Mar 2022 18:12:43 +0000 Subject: [PATCH] Relaunch on SIGUSR2 This is because Node uses SIGUSR1 to enable the debug listener so even if you just want to restart code-server you end up enabling the debug listener as well. Opted to leave the SIGUSR1 handler in to avoid breaking existing workflows even though it does mean even if you only want to enable the debug listener you will end up restarting code-server as well. We could consider removing it after a transition phase. --- src/node/wrapper.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/node/wrapper.ts b/src/node/wrapper.ts index c645fe83557d..42151ab1a617 100644 --- a/src/node/wrapper.ts +++ b/src/node/wrapper.ts @@ -203,8 +203,9 @@ class ChildProcess extends Process { /** * Parent process wrapper that spawns the child process and performs a handshake - * with it. Will relaunch the child if it receives a SIGUSR1 or is asked to by - * the child. If the child otherwise exits the parent will also exit. + * with it. Will relaunch the child if it receives a SIGUSR1 or SIGUSR2 or is + * asked to by the child. If the child otherwise exits the parent will also + * exit. */ export class ParentProcess extends Process { public logger = logger.named(`parent:${process.pid}`) @@ -227,6 +228,11 @@ export class ParentProcess extends Process { this.relaunch() }) + process.on("SIGUSR2", async () => { + this.logger.info("Received SIGUSR2; hotswapping") + this.relaunch() + }) + const opts = { size: "10M", maxFiles: 10,