mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 01:21:30 +00:00
Give thread pools time to terminate & Save all data before shutting down
This commit is contained in:
parent
539fa16160
commit
dad7821e26
@ -191,6 +191,9 @@ public final class Grasscutter {
|
||||
|
||||
/** Server shutdown event. */
|
||||
private static void onShutdown() {
|
||||
// Save all data.
|
||||
Database.saveAll();
|
||||
|
||||
// Disable all plugins.
|
||||
if (pluginManager != null) pluginManager.disablePlugins();
|
||||
// Shutdown the game server.
|
||||
@ -200,14 +203,14 @@ public final class Grasscutter {
|
||||
// Wait for Grasscutter's thread pool to finish.
|
||||
var executor = Grasscutter.getThreadPool();
|
||||
executor.shutdown();
|
||||
if (!executor.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
if (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
// Wait for database operations to finish.
|
||||
var dbExecutor = DatabaseHelper.getEventExecutor();
|
||||
dbExecutor.shutdown();
|
||||
if (!dbExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
if (!dbExecutor.awaitTermination(2, TimeUnit.MINUTES)) {
|
||||
dbExecutor.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
|
Loading…
Reference in New Issue
Block a user