Merge pull request #18 from TSRBerry/fix/socket-issues

Fix startup crash if the specified socket already exists
This commit is contained in:
Mary 2023-07-18 16:01:59 +02:00 committed by GitHub
commit 41feb2c58f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -1,10 +1,16 @@
import { env } from "process";
import { app, logger } from "./app";
import http from "http";
import { existsSync, rmSync } from "fs";
const server = http.createServer(app);
if (process.env.SOCKET_PATH != null && process.env.SOCKET_PATH.length > 0) {
// Remove the socket at the specified path if it already exists to avoid EADDRINUSE
if (existsSync(process.env.SOCKET_PATH)) {
rmSync(process.env.SOCKET_PATH);
}
server.listen({
path: process.env.SOCKET_PATH,
readableAll: true,