Skip to content
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

ServerLifecycleEvents documentation does not indicate it will not be triggered after datagen. #3945

Open
solonovamax opened this issue Jul 16, 2024 · 0 comments

Comments

@solonovamax
Copy link

solonovamax commented Jul 16, 2024

Copying this over from FabricMC/fabric-loom#1145 because I accidentally opened the issue on the wrong repo. (oopsies)

Issue

Unclear documentation in ServerLifecycleEvents causes events to be misappropriately used in certain scenarios.

When using datagen in a dev env, ServerLifecycleEvents are not triggered.

This can cause issues with mods/apis that, for example, rely on ServerLifecycleEvents.SERVER_STOPPING to clean up some resources.

As an example, I ran into this issue with AzureDoom/AzureLib#62, where a thread executor is spawned in non-daemon mode, and will be closed down when the ServerLifecycleEvents.SERVER_STOPPING event is emitted.
However, since it is never emitted, this causes the datagen to never exit, as the jvm sees that there's an active thread that is not marked as a daemon thread.

Should ServerLifecycleEvents.SERVER_STOPPING be emitted when the datagen finishes, or should it be added to the docs to not use it for cleaning up resources, as it can fail during datagen?


Proposed Solution

Documentation for SERVER_STOPPING and SERVER_STOPPED should be updated to mention

it is recommended that this event only be used for cleaning up resources that are created during SERVER_STARTING and SERVER_STARTED.
This event will not be emitted when using datagenning, and thus should be avoided by libraries for cleaning up resources (such as thread pools, databases, etc.) that were not started during SERVER_STARTING or SERVER_STARTED, as it will cause them to not get cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant