summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-02-27 11:05:39 +0100
committerRory& <root@rory.gay>2026-02-27 11:10:10 +0100
commit9abff8337828fdaffcccd5fe32a211771cfbbbe9 (patch)
tree8827152bebb59976c3f074bae6a9dcb3390e013e
parentIPC: eagerly init unix sockets on startup (diff)
downloadserver-ts-9abff8337828fdaffcccd5fe32a211771cfbbbe9.tar.xz
IPC: more unix socket logging
-rw-r--r--src/util/util/Event.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts

index b6020c61..08507dc7 100644 --- a/src/util/util/Event.ts +++ b/src/util/util/Event.ts
@@ -320,6 +320,15 @@ class UnixSocketListener { } } +function getPidCmdline(pid: number): string | null { + try { + const cmdline = fs.readFileSync(`/proc/${pid}/cmdline`, "utf-8"); + return cmdline.replaceAll("\0", " ").trim(); + } catch (e) { + return null; + } +} + class UnixSocketWriter { socketPath: string; clients: { [key: string]: Socket } = {}; @@ -336,6 +345,8 @@ class UnixSocketWriter { const connect = (file: string) => { const fullPath = path.join(this.socketPath, file); + const pid = Number(path.basename(file, ".sock")); + console.log("[Events] Attempting to connect to unix socket:", fullPath, "| proc:", getPidCmdline(pid) ?? red("No such pid: " + pid)); // avoid duplicate connections if (this.clients[fullPath] && !this.clients[fullPath].destroyed) { @@ -345,6 +356,7 @@ class UnixSocketWriter { // clean up old connection if it exists if (this.clients[fullPath]) { + console.log("[Events] Removing stale unix socket client for", fullPath); try { this.clients[fullPath].destroy(); } catch (e) {