Skip to content

Commit

Permalink
Fix shutdown behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdragh committed Dec 2, 2023
1 parent 4df6469 commit 83af232
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ fun startAstralbot(server: MinecraftServer) {

fun stopAstralbot() {
LOGGER.info("Shutting down AstralBot")
LOGGER.info("JDA: {}", jda)
FAQHandler.stop()
jda?.shutdown()
LOGGER.info("Shutting JDA")
jda?.shutdownNow()
LOGGER.info("After shutdownNow")
jda?.awaitShutdown()
LOGGER.info("Shut down AstralBot")
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.io.path.nameWithoutExtension
object FAQHandler {
private val faqDirectory = File("faq")
private val availableFAQIDs = HashSet<String>()
private lateinit var watcher: FileWatcher
private var watcher: FileWatcher? = null

fun start() {
LOGGER.info("FAQHandler loading")
Expand All @@ -36,7 +36,7 @@ object FAQHandler {
}
}
}
watcher.startWatching()
watcher?.startWatching()

LOGGER.info("FAQHandler loaded")
}
Expand All @@ -58,7 +58,7 @@ object FAQHandler {

fun stop() {
LOGGER.info("Shutting down FileSystem Watcher")
watcher.stopWatching()
watcher?.stopWatching()
}
}

0 comments on commit 83af232

Please sign in to comment.