mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(tray): kill child PID before IPC close to avoid macOS NSStatusItem orphan
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -685,6 +685,11 @@ function startServer(latestVersion) {
|
|||||||
const { clearScreen } = require("./src/cli/utils/display");
|
const { clearScreen } = require("./src/cli/utils/display");
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
|
// Kill current tray FIRST so the new bgProcess can register a fresh
|
||||||
|
// NSStatusItem on macOS without conflicting with the orphan binary
|
||||||
|
try { require("./src/cli/tray/tray").killTray(); } catch (e) { }
|
||||||
|
await new Promise(r => setTimeout(r, 300));
|
||||||
|
|
||||||
// Enable auto startup on OS boot
|
// Enable auto startup on OS boot
|
||||||
try {
|
try {
|
||||||
const { enableAutoStart } = require("./src/cli/tray/autostart");
|
const { enableAutoStart } = require("./src/cli/tray/autostart");
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "9router",
|
"name": "9router",
|
||||||
"version": "0.4.44",
|
"version": "0.4.45",
|
||||||
"description": "9Router CLI - Start and manage 9Router server",
|
"description": "9Router CLI - Start and manage 9Router server",
|
||||||
"bin": {
|
"bin": {
|
||||||
"9router": "./cli.js"
|
"9router": "./cli.js"
|
||||||
|
|||||||
@@ -255,10 +255,19 @@ function killTray() {
|
|||||||
if (instance) {
|
if (instance) {
|
||||||
try {
|
try {
|
||||||
if (wasWin) instance.kill();
|
if (wasWin) instance.kill();
|
||||||
// systray2.kill(true) defaults to calling process.exit(0) which aborts
|
else {
|
||||||
// the rest of cleanup (server SIGKILL, MITM/tunnel cleanup). Pass false
|
// systray2.kill(false) closes IPC but leaves the Go tray binary
|
||||||
// so callers stay in control of process exit.
|
// subprocess running, which keeps an orphan NSStatusItem on macOS
|
||||||
else instance.kill(false);
|
// and blocks a freshly spawned tray (e.g. hide-to-tray bgProcess)
|
||||||
|
// from registering. Kill the child PID directly first.
|
||||||
|
try {
|
||||||
|
const proc = instance._process || (typeof instance.process === "function" ? instance.process() : null);
|
||||||
|
if (proc && proc.pid) {
|
||||||
|
process.kill(proc.pid, "SIGKILL");
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
instance.kill(false);
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "9router-app",
|
"name": "9router-app",
|
||||||
"version": "0.4.44",
|
"version": "0.4.45",
|
||||||
"description": "9Router web dashboard",
|
"description": "9Router web dashboard",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user