From 13fac2d5bcf58c7a2225b7ff7adde9ff1318f459 Mon Sep 17 00:00:00 2001 From: Balki Date: Tue, 18 Mar 2025 18:20:05 +0000 Subject: [PATCH 1/2] Support http server listening on unix socket --- server/Server.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/Server.js b/server/Server.js index c3e73aec..fde5343e 100644 --- a/server/Server.js +++ b/server/Server.js @@ -395,10 +395,19 @@ class Server { }) router.get('/healthcheck', (req, res) => res.sendStatus(200)) - this.server.listen(this.Port, this.Host, () => { - if (this.Host) Logger.info(`Listening on http://${this.Host}:${this.Port}`) - else Logger.info(`Listening on port :${this.Port}`) - }) + const unixSocketPrefix = "unix/" + if(this.Host.startsWith(unixSocketPrefix)) { + const sockPath = this.Host.slice(unixSocketPrefix.length) + this.server.listen(sockPath, () => { + fs.chmodSync(sockPath, 0o666) + Logger.info(`Listening on unix socket ${sockPath}`) + }) + } else { + this.server.listen(this.Port, this.Host, () => { + if (this.Host) Logger.info(`Listening on http://${this.Host}:${this.Port}`) + else Logger.info(`Listening on port :${this.Port}`) + }) + } // Start listening for socket connections SocketAuthority.initialize(this) From 635c384952a76708e83078fa9c4488156f4f0092 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 16 May 2025 16:14:13 -0500 Subject: [PATCH 2/2] Handle undefined Host and make chmod async --- server/Server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/Server.js b/server/Server.js index fde5343e..40b6eb6f 100644 --- a/server/Server.js +++ b/server/Server.js @@ -395,11 +395,11 @@ class Server { }) router.get('/healthcheck', (req, res) => res.sendStatus(200)) - const unixSocketPrefix = "unix/" - if(this.Host.startsWith(unixSocketPrefix)) { + const unixSocketPrefix = 'unix/' + if (this.Host?.startsWith(unixSocketPrefix)) { const sockPath = this.Host.slice(unixSocketPrefix.length) - this.server.listen(sockPath, () => { - fs.chmodSync(sockPath, 0o666) + this.server.listen(sockPath, async () => { + await fs.chmod(sockPath, 0o666) Logger.info(`Listening on unix socket ${sockPath}`) }) } else {