由于Systemd服务文件管理逻辑运行于Spring程序启动之前,现在已经不需要刻意拦截Discord Bean的启动了

This commit is contained in:
2025-09-25 15:58:36 +08:00
parent 74a4b9a62c
commit 9067d67e8c
3 changed files with 3 additions and 5 deletions
@@ -30,7 +30,7 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("/message") @RequestMapping("/message")
class Message { class Message {
@Lazy @Autowired GatewayDiscordClient DiscordBotClient; @Autowired GatewayDiscordClient DiscordBotClient;
@Autowired List<String> ApiKeyList; @Autowired List<String> ApiKeyList;
@Schema(description = "包含了发送消息的数据包") @Schema(description = "包含了发送消息的数据包")
@@ -18,7 +18,6 @@ import java.util.List;
@Component @Component
class GlobalSharedBean { class GlobalSharedBean {
@Lazy
@Bean @Bean
GatewayDiscordClient GetDiscordClient(){ GatewayDiscordClient GetDiscordClient(){
String DiscordBotToken = System.getenv("Discord_Bot_Token"); String DiscordBotToken = System.getenv("Discord_Bot_Token");
@@ -174,6 +174,5 @@ public class SystemdInstallerManager{
log.info("成功删除指向程序自身的软链接: {}", SymbolicLinkPath); log.info("成功删除指向程序自身的软链接: {}", SymbolicLinkPath);
new ProcessBuilder("systemctl", "daemon-reload").start().waitFor(); new ProcessBuilder("systemctl", "daemon-reload").start().waitFor();
log.info("已完成systemd守护进程重载"); } log.info("已完成systemd守护进程重载"); }
System.exit(0); } } System.exit(0); } } }
// ↓ 并不是安装或卸载服务,于是继续正常的启动程序,让Discord客户端连接服务器,校验API密钥是否正确并确保密钥非空 }
DiscordClientProvider.getIfAvailable(); } }