improve: tell user that the WebUI is available #631
@ -13,11 +13,6 @@ import { customRouter } from "@/src/routes/custom";
|
|||||||
import { dynamicController } from "@/src/routes/dynamic";
|
import { dynamicController } from "@/src/routes/dynamic";
|
||||||
import { statsRouter } from "@/src/routes/stats";
|
import { statsRouter } from "@/src/routes/stats";
|
||||||
import { webuiRouter } from "@/src/routes/webui";
|
import { webuiRouter } from "@/src/routes/webui";
|
||||||
import { connectDatabase } from "@/src/services/mongoService";
|
|
||||||
import { registerLogFileCreationListener } from "@/src/utils/logger";
|
|
||||||
|
|
||||||
void registerLogFileCreationListener();
|
|
||||||
void connectDatabase();
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
36
src/index.ts
36
src/index.ts
@ -7,21 +7,29 @@ import https from "https";
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { app } from "./app";
|
import { app } from "./app";
|
||||||
import { config } from "./services/configService";
|
import { config } from "./services/configService";
|
||||||
//const morgan = require("morgan");
|
import { connectDatabase } from "@/src/services/mongoService";
|
||||||
//const bodyParser = require("body-parser");
|
import { registerLogFileCreationListener } from "@/src/utils/logger";
|
||||||
|
|
||||||
const options = {
|
registerLogFileCreationListener();
|
||||||
key: fs.readFileSync("static/certs/key.pem"),
|
|
||||||
cert: fs.readFileSync("static/certs/cert.pem")
|
|
||||||
};
|
|
||||||
|
|
||||||
const httpPort = config.httpPort || 80;
|
void (async (): Promise<void> => {
|
||||||
const httpsPort = config.httpsPort || 443;
|
await connectDatabase();
|
||||||
|
|
||||||
// const server = http.createServer(app).listen(80);
|
const httpPort = config.httpPort || 80;
|
||||||
http.createServer(app).listen(httpPort, () => logger.info("HTTP server started on port " + httpPort));
|
const httpsPort = config.httpsPort || 443;
|
||||||
|
|||||||
const server = https.createServer(options, app);
|
const options = {
|
||||||
server.listen(httpsPort, () => logger.info("HTTPS server started on port " + httpsPort));
|
key: fs.readFileSync("static/certs/key.pem"),
|
||||||
|
cert: fs.readFileSync("static/certs/cert.pem")
|
||||||
|
};
|
||||||
|
|
||||||
// server.keepAliveTimeout = 60 * 1000 + 1000;
|
http.createServer(app).listen(httpPort, () => {
|
||||||
// server.headersTimeout = 60 * 1000 + 2000;
|
logger.info("HTTP server started on port " + httpPort);
|
||||||
|
https.createServer(options, app).listen(httpsPort, () => {
|
||||||
|
logger.info("HTTPS server started on port " + httpsPort);
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"Access the WebUI in your browser at http://localhost" + (httpPort == 80 ? "" : ":" + httpPort)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
@ -8,7 +8,7 @@ if (url === undefined) {
|
|||||||
throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
|
throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
|
||||||
}
|
}
|
||||||
|
|
||||||
const connectDatabase = async () => {
|
export const connectDatabase = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
await mongoose.connect(`${url}`);
|
await mongoose.connect(`${url}`);
|
||||||
logger.info("Connected to MongoDB");
|
logger.info("Connected to MongoDB");
|
||||||
@ -18,5 +18,3 @@ const connectDatabase = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { connectDatabase };
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user
💡 Codebase verification
Based on the code analysis, I can now provide a final response:
Log file creation handling needs improvement
The current implementation of
registerLogFileCreationListener
only logs successful file creation/rotation events but lacks error handling. Consider adding error event listeners to handle potential file system issues:errorLog
andcombinedLog
transportsExample:
🔗 Analysis chain
Consider verifying log file creation.
The function call “registerLogFileCreationListener()” looks fine. As a good practice, ensure any potential errors or edge cases (e.g., restricted file permissions) are handled or at least logged appropriately.
Let me search for the implementation of
registerLogFileCreationListener
to verify how it handles errors and edge cases.Let me check how
errorLog
andcombinedLog
are initialized and if they handle file system errors properly.Let me search for error handling around the log file creation.
Let me check how the logger is configured and if there's any error handling at the transport level.
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
Length of output: 1795
Script:
Length of output: 82850
Script:
Length of output: 1793
Script:
Length of output: 709