Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Enhance & expose shutdown tracking #6

Open
Ribesg opened this issue Sep 10, 2014 · 4 comments
Open

Enhance & expose shutdown tracking #6

Ribesg opened this issue Sep 10, 2014 · 4 comments

Comments

@Ribesg
Copy link

Ribesg commented Sep 10, 2014

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.
@turt2live
Copy link

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

@Ribesg
Copy link
Author

Ribesg commented Sep 10, 2014

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

@turt2live
Copy link

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
GlowstoneMC/Glowkit#6 (comment).

@mastercoms
Copy link
Member

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.

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

No branches or pull requests

3 participants