Skip to content

Add structures to support hot restarting #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 31 commits into
base: 3.X
Choose a base branch
from
Draft

Conversation

freya022
Copy link
Owner

@freya022 freya022 commented May 31, 2025

Depends on freya022/BotCommands-Restarter#1

Deprecations

  • Deprecated BotCommands#create(<configuration block>)
    • Added an overload accepting the arguments of the main method
  • Deprecated JDAConfiguration.DevTools
    • Replaced with shutdownTimeout in BConfig, which applies to the entire framework's shutdown

New Features

  • Added BContext#shutdown
  • Added BContext#shutdownNow
  • Added BContext#awaitShutdown
  • Added SHUTTING_DOWN and SHUTDOWN in BContext.Status
  • Added BConfig#enableShutdownHook
  • Added BConfig#shutdownTimeout
  • Added BConfig#args
    • Not directly configurable, passed in the entry point or retrieved from Spring
  • Added BRestartConfig
  • Added BShutdownEvent
  • Added ApplicationStartListener
    • Will most likely be only used by the restarter module

Changes

  • Made internal coroutine dispatchers use daemon threads
    • So the JVM can exit if the bot is shut down (assuming the user does not create more non-daemon threads)
  • Moved RequiresDefaultInjection to the API
  • Added isDaemon to namedDefaultScope, defaults to false (compatible)

To do

  • Don't activate outside of development environments
  • Fix trying to access JDA from a closed Spring ApplicationContext on shutdown
  • Have the JDA cache not have a bajillion gotchas
  • Docs
  • Fix resource leaks, if any (threads, classes referencing old restart class loaders)
  • Fix all TODOs

@freya022 freya022 added this to the v3.0 milestone May 31, 2025
@freya022 freya022 added type: feature V3 Targets BotCommands 3.x.x type: experimental Might not make it into a release labels May 31, 2025
freya022 added 7 commits May 31, 2025 19:49
So Jitpack can build it
Will instead make a PR to ClassGraph,
overriding class loaders isn't enough
As it has its own hook already
Fixes awaiting termination always waiting until the deadline
freya022 added 5 commits June 5, 2025 23:15
This is required for the JDA restart cache module,
as it will fire the READY status directly
Calling scheduleShutdownSignal more than once is not great
So it doesn't block the main thread unnecessarily,
getting the owners will block until the value is set anyway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: experimental Might not make it into a release type: feature V3 Targets BotCommands 3.x.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant