Fix startup crash if the specified socket already exists
This commit is contained in:
parent
b0c43b3571
commit
700e913b6a
1 changed files with 6 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue