Skip to content
Extraits de code Groupes Projets
Valider 732be164 rédigé par Tadeusz Sośnierz's avatar Tadeusz Sośnierz
Parcourir les fichiers

Make sure the bridge doesn't crash (and crashloop) it the token is invalid

parent 172fedf1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -214,20 +214,34 @@ async function run(): Promise<void> {
roomhandler.bindThirdparty();
try {
await startDiscordBot(discordbot);
log.info("Discordbot started successfully");
} catch (err) {
log.error(err);
log.error("Failure during startup. Exiting");
process.exit(1);
}
await appservice.begin();
log.info(`Started listening on port ${port}`);
}
async function startDiscordBot(discordbot: DiscordBot, falloffSeconds = 5) {
try {
await discordbot.init();
await discordbot.run();
log.info("Discordbot started successfully");
} catch (err) {
log.error(err);
log.error("Failure during startup. Exiting");
process.exit(1);
// no more than 5 minutes
const newFalloffSeconds = Math.min(falloffSeconds * 2, 5 * 60);
log.error(`Failed do start Discordbot: ${err.code}. Will try again in ${newFalloffSeconds} seconds`);
await new Promise((r, _) => setTimeout(r, newFalloffSeconds * 1000));
return startDiscordBot(discordbot, newFalloffSeconds);
}
}
run().catch((err) => {
log.error("A fatal error occurred during startup:", err);
process.exit(1);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter