mirror of
https://github.com/spacebarchat/server.git
synced 2026-07-26 01:31:04 +00:00
Clean up supposedly orphaned unix sockets
This commit is contained in:
@@ -101,16 +101,20 @@ export class UnixSocketWriter extends BaseEventWriter {
|
||||
});
|
||||
|
||||
this.clients[fullPath].on("error", (err) => {
|
||||
console.error("[UnixSocketWriter] Unix socket client error on", fullPath, ":", err);
|
||||
// clean up after error
|
||||
if (this.clients[fullPath]) {
|
||||
delete this.clients[fullPath];
|
||||
}
|
||||
|
||||
if ("code" in err && err.code == "ECONNREFUSED") {
|
||||
console.error("[UnixSocketWriter] Got ECONNREFUSED for socket", fullPath, " - assuming it is orphaned...");
|
||||
fs.unlinkSync(fullPath);
|
||||
} else console.error("[UnixSocketWriter] Unix socket client error on", fullPath, ":", err);
|
||||
});
|
||||
|
||||
// handle clean socket closure
|
||||
this.clients[fullPath].on("close", () => {
|
||||
console.log("[UnixSocketWriter] Unix socket client closed:", fullPath);
|
||||
this.clients[fullPath].on("close", (hadError) => {
|
||||
console.log("[UnixSocketWriter] Unix socket client closed:", fullPath, "- hadError:", hadError);
|
||||
delete this.clients[fullPath];
|
||||
this.openConnectionsMetric.set(Object.entries(this.clients).length);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user