fix(cli): restart stale clients after updates
This commit is contained in:
parent
f9d1d3b259
commit
910af9a122
13 changed files with 246 additions and 25 deletions
|
|
@ -6,8 +6,9 @@ const path = require("path")
|
|||
const os = require("os")
|
||||
|
||||
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
|
||||
const restartExitCode = 75
|
||||
|
||||
function run(target) {
|
||||
function run(target, restarted = false) {
|
||||
const child = childProcess.spawn(target, process.argv.slice(2), { stdio: "inherit" })
|
||||
child.on("error", (error) => {
|
||||
console.error(error.message)
|
||||
|
|
@ -25,6 +26,7 @@ function run(target) {
|
|||
child.on("exit", (code, signal) => {
|
||||
for (const forwardedSignal of forwardedSignals) process.removeListener(forwardedSignal, forwarders[forwardedSignal])
|
||||
if (signal) return process.kill(process.pid, signal)
|
||||
if (code === restartExitCode && !restarted) return run(target, true)
|
||||
process.exit(typeof code === "number" ? code : 0)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue