fix(logging): updated entire server side to the new logging system

This commit is contained in:
2025-03-07 13:40:29 -06:00
parent ce11b1f57e
commit 12e15babb4
33 changed files with 482 additions and 72 deletions

View File

@@ -4,7 +4,8 @@ import {OpenAPIHono} from "@hono/zod-openapi";
import {serveStatic} from "@hono/node-server/serve-static";
import {logger} from "hono/logger";
import {cors} from "hono/cors";
import {log} from "./services/logger/logger.js";
import {createLog} from "./services/logger/logger.js";
import {closePool} from "./services/sqlServer/prodSqlServer.js";
// custom routes
import scalar from "./services/general/route/scalar.js";
@@ -12,6 +13,8 @@ import system from "./services/server/systemServer.js";
import auth from "./services/auth/authService.js";
import tcpServer from "./services/tcpServer/tcpServer.js";
import ocme from "./services/ocme/ocmeService.js";
import sqlService from "./services/sqlServer/sqlService.js";
import logistics from "./services/logistics/logisticsService.js";
const allowedOrigins = ["http://localhost:3000", "http://localhost:4000", "http://localhost:5173"];
const app = new OpenAPIHono();
@@ -46,7 +49,7 @@ app.use("*", async (c, next) => {
app.doc("/api/ref", {
openapi: "3.0.0",
info: {
version: "1.0.0",
version: "2.0.0",
title: "LST API",
},
});
@@ -57,6 +60,8 @@ const routes = [
// apiHits,
system,
tcpServer,
sqlService,
logistics,
] as const;
const appRoutes = routes.forEach((route) => {
@@ -77,13 +82,37 @@ app.route("/ocme/", ocme);
app.use("/*", serveStatic({root: "./frontend/dist"}));
app.use("*", serveStatic({path: "./frontend/dist/index.html"}));
// Handle app exit signals
process.on("SIGINT", async () => {
console.log("\nGracefully shutting down...");
await closePool();
process.exit(0);
});
process.on("SIGTERM", async () => {
console.log("Received termination signal, closing database...");
await closePool();
process.exit(0);
});
process.on("uncaughtException", async (err) => {
console.log("Uncaught Exception:", err);
await closePool();
process.exit(1);
});
process.on("beforeExit", async () => {
console.log("Process is about to exit...");
await closePool();
});
serve(
{
fetch: app.fetch,
port: Number(process.env.VITE_SERVER_PORT),
},
(info) => {
log.info({username: "LST-SYSTEM"}, `Server is running on http://localhost:${info.port}`);
createLog("info", "LST", "server", `Server is running on http://localhost:${info.port}`);
}
);