mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import dotenv from "dotenv";
|
|
|
|
import { initDbConnection } from "./db";
|
|
import { keyStoreFactory } from "./keystore/keystore";
|
|
import { formatSmtpConfig, initEnvConfig } from "./lib/config/env";
|
|
import { initLogger } from "./lib/logger";
|
|
import { queueServiceFactory } from "./queue";
|
|
import { main } from "./server/app";
|
|
import { bootstrapCheck } from "./server/boot-strap-check";
|
|
import { smtpServiceFactory } from "./services/smtp/smtp-service";
|
|
|
|
dotenv.config();
|
|
const run = async () => {
|
|
const logger = await initLogger();
|
|
const appCfg = initEnvConfig(logger);
|
|
const db = initDbConnection({
|
|
dbConnectionUri: appCfg.DB_CONNECTION_URI,
|
|
dbRootCert: appCfg.DB_ROOT_CERT,
|
|
readReplicas: appCfg.DB_READ_REPLICAS?.map((el) => ({
|
|
dbRootCert: el.DB_ROOT_CERT,
|
|
dbConnectionUri: el.DB_CONNECTION_URI
|
|
}))
|
|
});
|
|
|
|
const smtp = smtpServiceFactory(formatSmtpConfig());
|
|
const queue = queueServiceFactory(appCfg.REDIS_URL);
|
|
const keyStore = keyStoreFactory(appCfg.REDIS_URL);
|
|
|
|
const server = await main({ db, smtp, logger, queue, keyStore });
|
|
const bootstrap = await bootstrapCheck({ db });
|
|
// eslint-disable-next-line
|
|
process.on("SIGINT", async () => {
|
|
await server.close();
|
|
await db.destroy();
|
|
process.exit(0);
|
|
});
|
|
|
|
// eslint-disable-next-line
|
|
process.on("SIGTERM", async () => {
|
|
await server.close();
|
|
await db.destroy();
|
|
process.exit(0);
|
|
});
|
|
|
|
await server.listen({
|
|
port: appCfg.PORT,
|
|
host: appCfg.HOST,
|
|
listenTextResolver: (address) => {
|
|
void bootstrap();
|
|
return address;
|
|
}
|
|
});
|
|
};
|
|
|
|
void run();
|