feat: relaunch on SIGUSR2 (#4979)

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.
This commit is contained in:
Asher 2022-04-27 10:10:48 -05:00 committed by GitHub
parent fc75db6edc
commit 4e93db5b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -203,8 +203,9 @@ class ChildProcess extends Process {
/** /**
* Parent process wrapper that spawns the child process and performs a handshake * 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 * with it. Will relaunch the child if it receives a SIGUSR1 or SIGUSR2 or is
* the child. If the child otherwise exits the parent will also exit. * asked to by the child. If the child otherwise exits the parent will also
* exit.
*/ */
export class ParentProcess extends Process { export class ParentProcess extends Process {
public logger = logger.named(`parent:${process.pid}`) public logger = logger.named(`parent:${process.pid}`)
@ -227,6 +228,11 @@ export class ParentProcess extends Process {
this.relaunch() this.relaunch()
}) })
process.on("SIGUSR2", async () => {
this.logger.info("Received SIGUSR2; hotswapping")
this.relaunch()
})
const opts = { const opts = {
size: "10M", size: "10M",
maxFiles: 10, maxFiles: 10,