Glowkit-Legacy icon indicating copy to clipboard operation
Glowkit-Legacy copied to clipboard

Enhance & expose shutdown tracking

Open Ribesg opened this issue 10 years ago • 4 comments

Here is a simple idea.

Various events may be thrown when the server shuts down but in other cases too, like PlayerQuitEvent. onDisable() can also be called when shutting down or when simply disabled for other reason.

That's why I suggest that there is a way to see is the server is currently shutting down.

It would for example allow to execute code synchronously instead of launching asynchronous tasks.

Examples:

  • Saving player-related data in PlayerQuitEvent usually done by an async task, but the server may shutdown at that point and kill this task.
  • Saving config/files synchronously in onDisable(). Usually you don't need to do anything async here because the server shuts down, but it just slow downs the server if the plugin has actually been disabled dynamically. I'm not sure about that one, maybe the plugin is no longer able to do anything after it has been disabled.

Ribesg avatar Sep 10 '14 16:09 Ribesg

It is not possible, or recommended, for the plugin to continue after disable.

turt2live avatar Sep 10 '14 16:09 turt2live

So disabling a plugin will always have to kinda-lockup the server if it does any saving/heavy stuff

Ribesg avatar Sep 10 '14 16:09 Ribesg

It should.

sent from mobile On Sep 10, 2014 10:36 AM, "Gael Ribes" [email protected] wrote:

So disabling a plugin will always have to kinda-lockup the server if it does any saving/heavy stuff

— Reply to this email directly or view it on GitHub https://github.com/GlowstoneMC/Glowkit/issues/6#issuecomment-55143442.

turt2live avatar Sep 10 '14 16:09 turt2live

Plugin can use Thread.interrupted() or Thread.isInterrupted() to do stuff when it is being shutdown. (only works if ShutdownMonitorThread in Glowstone is changed to use Thread.interrupt instead of Thread.stop, and only if the plugin does not fully stop after GlowServer disables them)

So it might not be a good idea to add onDisable() because only plugins that are continuing a task will continue running after disable, and they should check if they are interrupted anyway.

mastercoms avatar Sep 24 '14 10:09 mastercoms