fix: clean stale pid on stop (#1015)
This commit is contained in:
+14
-2
@@ -419,7 +419,14 @@ function startDaemon(port) {
|
||||
}
|
||||
|
||||
function stopDaemon() {
|
||||
const pid = getPid()
|
||||
const pidFromFile = readPidFile()
|
||||
if (pidFromFile && !isRunning(pidFromFile)) {
|
||||
removePid()
|
||||
console.log(` ✓ hermes-web-ui was not running (cleaned stale PID: ${pidFromFile})`)
|
||||
return
|
||||
}
|
||||
|
||||
const pid = pidFromFile ?? recoverPidFromPort()
|
||||
if (!pid) {
|
||||
console.log(' ✗ hermes-web-ui is not running')
|
||||
process.exit(1)
|
||||
@@ -442,7 +449,11 @@ function stopDaemon() {
|
||||
} catch {}
|
||||
// Force kill if still alive
|
||||
if (isRunning(pid)) {
|
||||
process.kill(pid, 'SIGKILL')
|
||||
try {
|
||||
process.kill(pid, 'SIGKILL')
|
||||
} catch (err) {
|
||||
if (err?.code !== 'ESRCH') throw err
|
||||
}
|
||||
}
|
||||
removePid()
|
||||
console.log(` ✓ hermes-web-ui stopped (PID: ${pid})`)
|
||||
@@ -701,4 +712,5 @@ export {
|
||||
getListeningPids,
|
||||
parseUnixNetstatListeningPids,
|
||||
resetDefaultLogin,
|
||||
stopDaemon,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user