fix : 디스코드 로그인 실패 시 1분마다 재시도 (NAS 부팅 직후 DNS 미준비)
deploy / deploy (push) Successful in 1m11s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-12-02 10:03:23 +09:00
1 parent 991044fe44
commit 93d815c7b5
1 file changed
+19 -6
+19 -6
View File
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpServer;
import net.dv8tion.jda.api.exceptions.InvalidTokenException;
import net.dv8tion.jda.api.exceptions.ParsingException; import net.dv8tion.jda.api.exceptions.ParsingException;
import net.dv8tion.jda.api.utils.data.DataArray; import net.dv8tion.jda.api.utils.data.DataArray;
import net.dv8tion.jda.api.utils.data.DataObject; import net.dv8tion.jda.api.utils.data.DataObject;
@@ -71,17 +72,29 @@ public class DiscordDownloadBot extends ListenerAdapter {
System.exit(1); System.exit(1);
} }
new File(BASE_DOWNLOAD_DIR).mkdirs(); new File(BASE_DOWNLOAD_DIR).mkdirs();
DiscordDownloadBot bot = new DiscordDownloadBot();
try { try {
DiscordDownloadBot bot = new DiscordDownloadBot();
bot.startHttpServer(); // 디스코드 로그인이 실패해도 홈페이지 창구는 살아 있도록 먼저 켬 bot.startHttpServer(); // 디스코드 로그인이 실패해도 홈페이지 창구는 살아 있도록 먼저 켬
JDABuilder.createDefault(BOT_TOKEN)
.enableIntents(GatewayIntent.MESSAGE_CONTENT)
.addEventListeners(bot)
.build();
System.out.println("🤖 봇 실행 완료! (더블 탭 전략)");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
// NAS가 막 켜졌을 땐 DNS가 아직 안 돼서 로그인이 실패함 → 1분마다 다시 시도 (토큰이 틀린 건 재시도해도 소용없으니 포기)
while (true) {
try {
JDABuilder.createDefault(BOT_TOKEN)
.enableIntents(GatewayIntent.MESSAGE_CONTENT)
.addEventListeners(bot)
.build();
System.out.println("🤖 봇 실행 완료! (더블 탭 전략)");
return;
} catch (InvalidTokenException e) {
System.err.println("BOT_TOKEN이 올바르지 않습니다. 디스코드 로그인 포기 (HTTP 창구는 계속 동작)");
return;
} catch (Exception e) {
System.err.println("⚠️ 디스코드 로그인 실패, 1분 뒤 다시 시도: " + e.getMessage());
try { Thread.sleep(60_000); } catch (InterruptedException ie) { return; }
}
}
} }
@Override @Override