mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix: 🚑 Sleep process instead of exiting it on error
Avoids Docker's auto-restart policy from causing infinite reboots and hanging the system
This commit is contained in:
parent
7ba0eb82f1
commit
c764cc044d
|
|
@ -34,7 +34,9 @@ export const setupDatabase = async (
|
|||
"Database",
|
||||
"Failed to connect to database. Please check your configuration.",
|
||||
);
|
||||
process.exit();
|
||||
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
// Migrate the database
|
||||
|
|
@ -52,7 +54,9 @@ export const setupDatabase = async (
|
|||
"Database",
|
||||
"Failed to migrate database. Please check your configuration.",
|
||||
);
|
||||
process.exit();
|
||||
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
info && (await logger.log(LogLevel.Info, "Database", "Database migrated"));
|
||||
|
|
|
|||
18
index.ts
18
index.ts
|
|
@ -38,6 +38,10 @@ if (config.meilisearch.enabled) {
|
|||
await connectMeili(dualServerLogger);
|
||||
}
|
||||
|
||||
process.on("SIGINT", () => {
|
||||
process.exit();
|
||||
});
|
||||
|
||||
// Check if database is reachable
|
||||
const postCount = await Note.getCount();
|
||||
|
||||
|
|
@ -73,7 +77,9 @@ if (isEntry) {
|
|||
"Server",
|
||||
chalk.gray(`${privateKey};${publicKey}`),
|
||||
);
|
||||
process.exit();
|
||||
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
// Try and import the key
|
||||
|
|
@ -104,7 +110,9 @@ if (isEntry) {
|
|||
"Server",
|
||||
"The JWT key could not be imported! You may generate a new one by removing the old one from the config and restarting the server (this will invalidate all current JWTs).",
|
||||
);
|
||||
process.exit();
|
||||
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
@ -142,7 +150,8 @@ if (isEntry) {
|
|||
`Generated key: ${chalk.gray(base64)}`,
|
||||
);
|
||||
|
||||
process.exit();
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +254,8 @@ if (config.frontend.enabled) {
|
|||
"Server",
|
||||
`Frontend URL is not a valid URL: ${config.frontend.url}`,
|
||||
);
|
||||
process.exit();
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
// Check if frontend is reachable
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ const parsed = await configValidator.safeParseAsync(config);
|
|||
if (!parsed.success) {
|
||||
console.error("Invalid config file:");
|
||||
console.error(fromZodError(parsed.error).message);
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ export const connectMeili = async (logger: MultiLogManager | LogManager) => {
|
|||
"Meilisearch",
|
||||
"Error while connecting to Meilisearch",
|
||||
);
|
||||
process.exit();
|
||||
// Hang until Ctrl+C is pressed
|
||||
await Bun.sleep(Number.POSITIVE_INFINITY);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue