enhance(backend): add unix socket support (#11275)

* unix socket support

* add changelog

* lint

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
dogcraft 2023-07-17 13:12:02 +08:00 committed by GitHub
parent 4f22176b8f
commit 5dab918999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 3 deletions

View file

@ -224,7 +224,18 @@ export class ServerService implements OnApplicationShutdown {
}
});
fastify.listen({ port: this.config.port, host: '0.0.0.0' });
if (this.config.socket) {
if (fs.existsSync(this.config.socket)) {
fs.unlinkSync(this.config.socket);
}
fastify.listen({ path: this.config.socket }, (err, address) => {
if (this.config.chmodSocket) {
fs.chmodSync(this.config.socket!, this.config.chmodSocket);
}
});
} else {
fastify.listen({ port: this.config.port, host: '0.0.0.0' });
}
await fastify.ready();
}