mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 07:10:53 +00:00
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
|
import APIReferenceRoutes from "./Routes";
|
||
|
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
||
|
import InfrastructureStatus from "Common/Server/Infrastructure/Status";
|
||
|
import logger from "Common/Server/Utils/Logger";
|
||
|
import App from "Common/Server/Utils/StartServer";
|
||
|
import Telemetry from "Common/Server/Utils/Telemetry";
|
||
|
import "ejs";
|
||
|
|
||
|
const APP_NAME: string = "reference";
|
||
|
|
||
|
const init: PromiseVoidFunction = async (): Promise<void> => {
|
||
|
try {
|
||
|
// Initialize telemetry
|
||
|
Telemetry.init({
|
||
|
serviceName: APP_NAME,
|
||
|
});
|
||
|
|
||
|
const statusCheck: PromiseVoidFunction = async (): Promise<void> => {
|
||
|
// Check the status of infrastructure components
|
||
|
return await InfrastructureStatus.checkStatus({
|
||
|
checkClickhouseStatus: false,
|
||
|
checkPostgresStatus: false,
|
||
|
checkRedisStatus: false,
|
||
|
});
|
||
|
};
|
||
|
|
||
|
// Initialize the app with service name and status checks
|
||
|
await App.init({
|
||
|
appName: APP_NAME,
|
||
|
statusOptions: {
|
||
|
liveCheck: statusCheck,
|
||
|
readyCheck: statusCheck,
|
||
|
},
|
||
|
});
|
||
|
|
||
|
await APIReferenceRoutes.init();
|
||
|
|
||
|
// Add default routes to the app
|
||
|
await App.addDefaultRoutes();
|
||
|
} catch (err) {
|
||
|
logger.error("App Init Failed:");
|
||
|
logger.error(err);
|
||
|
throw err;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
init().catch((err: Error) => {
|
||
|
logger.error(err);
|
||
|
logger.error("Exiting node process");
|
||
|
process.exit(1);
|
||
|
});
|