forked from OpenWF/SpaceNinjaServer
improve: tell user that the WebUI is available (#631)
This commit is contained in:
parent
45cb9c6da0
commit
063adb3519
@ -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