Minor app fixes and improvements.

This commit is contained in:
Patrick FIc
2025-04-01 17:23:41 -07:00
parent e4f204bf38
commit 20f2963330
8 changed files with 92 additions and 63 deletions

View File

@@ -148,17 +148,23 @@ export default class LocalServer {
public start(): void {
try {
this.server = this.app.listen(this.PORT, (error: Error | undefined) => {
if (error) {
this.server = http.createServer(this.app);
this.server.on("error", (error: NodeJS.ErrnoException) => {
if (error.code === "EADDRINUSE") {
log.error(
`[HTTP Server] Error starting server: ${errorTypeCheck(error)}`,
`[HTTP Server] Port ${this.PORT} is already in use. Please use a different port.`,
);
} else {
log.info(
`[HTTP Server] Local HTTP server running on port ${this.PORT}`,
);
log.error(`[HTTP Server] Server error: ${error.message}`);
}
});
this.server.listen(this.PORT, () => {
log.info(
`[HTTP Server] Local HTTP server running on port ${this.PORT}`,
);
});
} catch (error: unknown) {
log.error("[HTTP Server] Error starting server", errorTypeCheck(error));
}