fix shutdown db saving
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 47s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 47s
This commit is contained in:
parent
78daf4531b
commit
96486bb3a1
@ -39,16 +39,15 @@ public class BatApplication {
|
||||
}
|
||||
log.info("Found configuration at '{}'", config.getAbsolutePath()); // Log the found config
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
log.info("Shutting down...");
|
||||
for (EventListener listener : EventService.LISTENERS) {
|
||||
listener.onShutdown();
|
||||
}
|
||||
}));
|
||||
|
||||
// Start the app
|
||||
SpringApplication.run(BatApplication.class, args);
|
||||
log.info("APP IS RUNNING IN %s MODE!!!!!!!!!".formatted(Config.isProduction() ? "PRODUCTION" : "DEVELOPMENT"));
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void onShutdown() {
|
||||
log.info("Shutting down...");
|
||||
for (EventListener listener : EventService.LISTENERS) {
|
||||
listener.onSpringShutdown();
|
||||
}
|
||||
}
|
||||
}
|
@ -243,8 +243,8 @@ public interface EventListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when Spring is shutting down
|
||||
* Called when Bat is shutting down
|
||||
*/
|
||||
default void onSpringShutdown() {
|
||||
default void onShutdown() {
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class ChannelListener implements EventListener {
|
||||
if (!joined) {
|
||||
lastVoiceChannel.remove(user);
|
||||
}
|
||||
log.info("User \"{}\" {} voice channel \"{}\" in guild \"{}\"", user.getId(), joined ? "joined" : "left", voiceChannel.getName(), guild.getName());
|
||||
log.info("User \"{}\" {} voice channel \"{}\" in guild \"{}\"", user.getName(), joined ? "joined" : "left", voiceChannel.getName(), guild.getName());
|
||||
String description = new EmbedDescriptionBuilder("User %s Voice Channel".formatted(joined ? "Joined" : "Left"))
|
||||
.appendLine("User: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||
.appendLine("Channel: %s".formatted(voiceChannel.getAsMention()), true)
|
||||
|
@ -114,7 +114,7 @@ public class GuildService extends ListenerAdapter implements EventListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpringShutdown() {
|
||||
public void onShutdown() {
|
||||
log.info("Saving all guilds before shutdown...");
|
||||
for (BatGuild guild : guilds.values()) {
|
||||
guild.save();
|
||||
|
@ -83,7 +83,7 @@ public class UserService implements EventListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpringShutdown() {
|
||||
public void onShutdown() {
|
||||
log.info("Saving all users before shutdown...");
|
||||
for (BatUser user : users.values()) {
|
||||
user.save();
|
||||
@ -93,7 +93,7 @@ public class UserService implements EventListener {
|
||||
|
||||
@Override
|
||||
public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) {
|
||||
user.setGlobalName(event.getUser().getName()); // Ensure the user's name is up-to-date
|
||||
user.setGlobalName(event.getUser().getGlobalName()); // Ensure the user's name is up-to-date
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user