mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-07 14:28:09 +03:00
Set bootInfo: true on all bootInfo requests
This commit is contained in:
Vendored
+4
-2
@@ -51,7 +51,7 @@ if (Environment.nodeEnv === "test") {
|
||||
dbName = `testingdb`;
|
||||
}
|
||||
|
||||
logger.info(`Connecting to database ${Environment.mongoUrl}/${dbName}...`);
|
||||
logger.info(`Connecting to database ${Environment.mongoUrl}/${dbName}...`, { bootInfo: true });
|
||||
const dbtime = process.hrtime.bigint();
|
||||
|
||||
// By default the connectTimeoutMS is 30 seconds. This has been upped to 2 minutes, due to poor performance
|
||||
@@ -63,7 +63,9 @@ export const monkDB = monk(`${Environment.mongoUrl}/${dbName}`, {
|
||||
/* istanbul ignore next */
|
||||
monkDB
|
||||
.then(() => {
|
||||
logger.info(`Database connection successful: took ${GetMilisecondsSince(dbtime)}ms`);
|
||||
logger.info(`Database connection successful: took ${GetMilisecondsSince(dbtime)}ms`, {
|
||||
bootInfo: true,
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.crit(err);
|
||||
|
||||
Vendored
+5
-3
@@ -6,14 +6,14 @@ import { GetMilisecondsSince } from "utils/misc";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
logger.verbose("Instantiated Redis Store");
|
||||
logger.verbose("Instantiated Redis Store", { bootInfo: true });
|
||||
|
||||
export const RedisClient = redis.createClient({
|
||||
url: `redis://${Environment.redisUrl}`,
|
||||
});
|
||||
const startConnect = process.hrtime.bigint();
|
||||
|
||||
logger.verbose("Instantiated Redis Client");
|
||||
logger.verbose("Instantiated Redis Client", { bootInfo: true });
|
||||
|
||||
function EmitCritical() {
|
||||
/* istanbul ignore next */
|
||||
@@ -27,7 +27,9 @@ function EmitCritical() {
|
||||
const ref = setTimeout(EmitCritical, ONE_MINUTE * 2);
|
||||
|
||||
RedisClient.on("connect", () => {
|
||||
logger.info(`Connected to Redis. Took ${GetMilisecondsSince(startConnect)}ms`);
|
||||
logger.info(`Connected to Redis. Took ${GetMilisecondsSince(startConnect)}ms`, {
|
||||
bootInfo: true,
|
||||
});
|
||||
|
||||
clearTimeout(ref);
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ const logger = CreateLogCtx(__filename);
|
||||
let transporter: Transporter | undefined;
|
||||
|
||||
if (ServerConfig.EMAIL_CONFIG) {
|
||||
logger.info(`Connecting to email server...`);
|
||||
logger.info(`Connecting to email server...`, { bootInfo: true });
|
||||
const conf = ServerConfig.EMAIL_CONFIG;
|
||||
|
||||
try {
|
||||
@@ -37,7 +37,9 @@ if (ServerConfig.EMAIL_CONFIG) {
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
logger.warn(`No EMAIL_CONFIG present in conf, emails will not be sent from the server.`);
|
||||
logger.warn(`No EMAIL_CONFIG present in conf, emails will not be sent from the server.`, {
|
||||
bootInfo: true,
|
||||
});
|
||||
}
|
||||
|
||||
export function SendEmail(
|
||||
|
||||
+18
-12
@@ -17,10 +17,12 @@ import { CloseRedisConnection } from "external/redis/redis";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
logger.info(`Booting ${TachiConfig.NAME} - ${FormatVersion()} [ENV: ${Environment.nodeEnv}]`);
|
||||
logger.info(`Log level is set to ${ServerConfig.LOGGER_CONFIG.LOG_LEVEL}.`);
|
||||
logger.info(`Booting ${TachiConfig.NAME} - ${FormatVersion()} [ENV: ${Environment.nodeEnv}]`, {
|
||||
bootInfo: true,
|
||||
});
|
||||
logger.info(`Log level is set to ${ServerConfig.LOGGER_CONFIG.LOG_LEVEL}.`, { bootInfo: true });
|
||||
|
||||
logger.info(`Loading sequence documents...`);
|
||||
logger.info(`Loading sequence documents...`, { bootInfo: true });
|
||||
|
||||
async function RunOnInit() {
|
||||
await InitSequenceDocs();
|
||||
@@ -52,7 +54,8 @@ let instance: http.Server | https.Server;
|
||||
|
||||
if (ServerConfig.ENABLE_SERVER_HTTPS) {
|
||||
logger.warn(
|
||||
"HTTPS Mode is enabled. This should not be used in production, and you should instead run behind a reverse proxy."
|
||||
"HTTPS Mode is enabled. This should not be used in production, and you should instead run behind a reverse proxy.",
|
||||
{ bootInfo: true }
|
||||
);
|
||||
const privateKey = fs.readFileSync("./cert/key.pem");
|
||||
const certificate = fs.readFileSync("./cert/cert.pem");
|
||||
@@ -60,32 +63,35 @@ if (ServerConfig.ENABLE_SERVER_HTTPS) {
|
||||
const httpsServer = https.createServer({ key: privateKey, cert: certificate }, server);
|
||||
|
||||
instance = httpsServer.listen(Environment.port);
|
||||
logger.info(`HTTPS Listening on port ${Environment.port}`);
|
||||
logger.info(`HTTPS Listening on port ${Environment.port}`, { bootInfo: true });
|
||||
} else {
|
||||
instance = server.listen(Environment.port);
|
||||
logger.info(`HTTP Listening on port ${Environment.port}`);
|
||||
logger.info(`HTTP Listening on port ${Environment.port}`, { bootInfo: true });
|
||||
}
|
||||
|
||||
process.on("SIGTERM", () => {
|
||||
logger.info("SIGTERM Received, closing program.");
|
||||
logger.info("SIGTERM Received, closing program.", { shutdownInfo: true });
|
||||
|
||||
instance.close(async () => {
|
||||
logger.info("Closing Mongo Database.");
|
||||
logger.info("Closing Mongo Database.", { shutdownInfo: true });
|
||||
await monkDB.close();
|
||||
|
||||
logger.info("Closing Redis Connection.");
|
||||
logger.info("Closing Redis Connection.", { shutdownInfo: true });
|
||||
CloseRedisConnection();
|
||||
|
||||
logger.info("Everything closed. Waiting for process to exit naturally.");
|
||||
logger.info("Everything closed. Waiting for process to exit naturally.", {
|
||||
shutdownInfo: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (process.env.INVOKE_JOB_RUNNER) {
|
||||
logger.info(`Spawning a tachi-server job runner inline.`);
|
||||
logger.info(`Spawning a tachi-server job runner inline.`, { bootInfo: true });
|
||||
|
||||
if (Environment.nodeEnv === "production") {
|
||||
logger.warn(
|
||||
`Spawning inline tachi-server job runner in production. Is this actually what you want? You should run a tool like Ofelia to manage this.`
|
||||
`Spawning inline tachi-server job runner in production. Is this actually what you want? You should run a tool like Ofelia to manage this.`,
|
||||
{ bootInfo: true }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@ const userSessionMiddleware = expressSession({
|
||||
const app: Express = express();
|
||||
|
||||
if (Environment.nodeEnv !== "production" && ServerConfig.CLIENT_DEV_SERVER) {
|
||||
logger.warn(`Enabling CORS requests from ${ServerConfig.CLIENT_DEV_SERVER}.`);
|
||||
logger.warn(`Enabling CORS requests from ${ServerConfig.CLIENT_DEV_SERVER}.`, {
|
||||
bootInfo: true,
|
||||
});
|
||||
|
||||
// Allow CORS requests from another server (since we have our dev server hosted separately).
|
||||
app.use((req, res, next) => {
|
||||
@@ -61,7 +63,9 @@ if (Environment.nodeEnv !== "production" && ServerConfig.CLIENT_DEV_SERVER) {
|
||||
}
|
||||
} else {
|
||||
if (Environment.nodeEnv !== "test") {
|
||||
logger.info("Enabling Helmet, as no CLIENT_DEV_SERVER was set, or we are in production.");
|
||||
logger.info("Enabling Helmet, as no CLIENT_DEV_SERVER was set, or we are in production.", {
|
||||
bootInfo: true,
|
||||
});
|
||||
}
|
||||
app.use(helmet());
|
||||
}
|
||||
@@ -110,10 +114,11 @@ app.use("/", mainRouter);
|
||||
if (ServerConfig.RUN_OWN_CDN) {
|
||||
if (Environment.nodeEnv === "production") {
|
||||
logger.warn(
|
||||
`Running OWN_CDN in production. Consider making a separate process handle your CDN for performance.`
|
||||
`Running OWN_CDN in production. Consider making a separate process handle your CDN for performance.`,
|
||||
{ bootInfo: true }
|
||||
);
|
||||
} else if (Environment.nodeEnv !== "test") {
|
||||
logger.info(`Running own CDN at ${Environment.cdnRoot}.`);
|
||||
logger.info(`Running own CDN at ${Environment.cdnRoot}.`, { bootInfo: true });
|
||||
}
|
||||
|
||||
app.use("/cdn", express.static(Environment.cdnRoot));
|
||||
|
||||
Reference in New Issue
Block a user