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> { ...@@ -214,20 +214,34 @@ async function run(): Promise<void> {
roomhandler.bindThirdparty(); 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(); await appservice.begin();
log.info(`Started listening on port ${port}`); log.info(`Started listening on port ${port}`);
}
async function startDiscordBot(discordbot: DiscordBot, falloffSeconds = 5) {
try { try {
await discordbot.init(); await discordbot.init();
await discordbot.run(); await discordbot.run();
log.info("Discordbot started successfully");
} catch (err) { } catch (err) {
log.error(err); // no more than 5 minutes
log.error("Failure during startup. Exiting"); const newFalloffSeconds = Math.min(falloffSeconds * 2, 5 * 60);
process.exit(1); 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) => { run().catch((err) => {
log.error("A fatal error occurred during startup:", err); log.error("A fatal error occurred during startup:", err);
process.exit(1); 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