2024-04-24 17:26:13 +00:00
|
|
|
process.env['SERVICE_NAME'] = 'ingress';
|
|
|
|
|
2024-01-29 07:23:24 +00:00
|
|
|
import logger from 'CommonServer/Utils/Logger';
|
|
|
|
import App from 'CommonServer/Utils/StartServer';
|
|
|
|
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
|
2024-04-30 16:34:15 +00:00
|
|
|
import AcmeWriteCertificatesJob from './Jobs/AcmeWriteCertificates';
|
2024-02-27 15:56:47 +00:00
|
|
|
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
|
2024-04-24 17:26:13 +00:00
|
|
|
import InfrastructureStatus from 'CommonServer/Infrastructure/Status';
|
2024-01-29 07:23:24 +00:00
|
|
|
|
2024-04-24 17:26:13 +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-01-29 07:23:24 +00:00
|
|
|
try {
|
2024-04-24 17:26:13 +00:00
|
|
|
const statusCheck: PromiseVoidFunction = async (): Promise<void> => {
|
|
|
|
return await InfrastructureStatus.checkStatus({
|
|
|
|
checkClickhouseStatus: false,
|
|
|
|
checkPostgresStatus: true,
|
|
|
|
checkRedisStatus: false,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-01-29 07:23:24 +00:00
|
|
|
// init the app
|
2024-04-24 16:44:29 +00:00
|
|
|
await App.init({
|
2024-04-24 13:02:17 +00:00
|
|
|
appName: APP_NAME,
|
|
|
|
port: undefined,
|
|
|
|
isFrontendApp: false,
|
|
|
|
statusOptions: {
|
2024-04-24 17:26:13 +00:00
|
|
|
liveCheck: statusCheck,
|
|
|
|
readyCheck: statusCheck,
|
2024-04-24 13:02:17 +00:00
|
|
|
},
|
|
|
|
});
|
2024-01-29 07:23:24 +00:00
|
|
|
|
|
|
|
// connect to the database.
|
|
|
|
await PostgresAppInstance.connect(
|
|
|
|
PostgresAppInstance.getDatasourceOptions()
|
|
|
|
);
|
|
|
|
|
2024-04-30 18:12:03 +00:00
|
|
|
AcmeWriteCertificatesJob.init();
|
2024-04-30 16:34:15 +00:00
|
|
|
|
2024-04-24 16:44:29 +00:00
|
|
|
// add default routes
|
|
|
|
await App.addDefaultRoutes();
|
2024-01-29 07:23:24 +00:00
|
|
|
} catch (err) {
|
|
|
|
logger.error('App Init Failed:');
|
|
|
|
logger.error(err);
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
init().catch((err: Error) => {
|
|
|
|
logger.error(err);
|
|
|
|
logger.info('Exiting node process');
|
|
|
|
process.exit(1);
|
|
|
|
});
|