2024-06-14 11:09:53 +00:00
|
|
|
import AcmeWriteCertificatesJob from "./Jobs/AcmeWriteCertificates";
|
2024-10-09 18:24:17 +00:00
|
|
|
import WriteCustomCertsToDiskJob from "./Jobs/WriteCustomCertsToDisk";
|
2024-06-14 11:09:53 +00:00
|
|
|
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
2024-08-20 16:37:45 +00:00
|
|
|
import PostgresAppInstance from "Common/Server/Infrastructure/PostgresDatabase";
|
2024-08-07 21:50:32 +00:00
|
|
|
import InfrastructureStatus from "Common/Server/Infrastructure/Status";
|
|
|
|
import logger from "Common/Server/Utils/Logger";
|
|
|
|
import App from "Common/Server/Utils/StartServer";
|
2024-05-29 14:25:09 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
process.env["SERVICE_NAME"] = "ingress";
|
2024-01-29 07:23:24 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
const APP_NAME: string = process.env["SERVICE_NAME"];
|
2024-01-29 07:23:24 +00:00
|
|
|
|
2024-02-27 15:37:49 +00:00
|
|
|
const init: PromiseVoidFunction = async (): Promise<void> => {
|
2024-06-14 11:09:53 +00:00
|
|
|
try {
|
|
|
|
const statusCheck: PromiseVoidFunction = async (): Promise<void> => {
|
|
|
|
return await InfrastructureStatus.checkStatus({
|
|
|
|
checkClickhouseStatus: false,
|
|
|
|
checkPostgresStatus: true,
|
|
|
|
checkRedisStatus: false,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// init the app
|
|
|
|
await App.init({
|
|
|
|
appName: APP_NAME,
|
|
|
|
port: undefined,
|
|
|
|
isFrontendApp: false,
|
|
|
|
statusOptions: {
|
|
|
|
liveCheck: statusCheck,
|
|
|
|
readyCheck: statusCheck,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// connect to the database.
|
2024-08-13 11:12:17 +00:00
|
|
|
await PostgresAppInstance.connect();
|
2024-06-14 11:09:53 +00:00
|
|
|
|
|
|
|
AcmeWriteCertificatesJob.init();
|
2024-10-09 18:24:17 +00:00
|
|
|
WriteCustomCertsToDiskJob.init();
|
2024-06-14 11:09:53 +00:00
|
|
|
|
|
|
|
// add default routes
|
|
|
|
await App.addDefaultRoutes();
|
|
|
|
} catch (err) {
|
|
|
|
logger.error("App Init Failed:");
|
|
|
|
logger.error(err);
|
|
|
|
throw err;
|
|
|
|
}
|
2024-01-29 07:23:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
init().catch((err: Error) => {
|
2024-06-14 11:09:53 +00:00
|
|
|
logger.error(err);
|
|
|
|
logger.error("Exiting node process");
|
|
|
|
process.exit(1);
|
2024-01-29 07:23:24 +00:00
|
|
|
});
|