mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 06:50:36 +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. */
|
/** Server shutdown event. */
|
||||||
private static void onShutdown() {
|
private static void onShutdown() {
|
||||||
|
// Save all data.
|
||||||
|
Database.saveAll();
|
||||||
|
|
||||||
// Disable all plugins.
|
// Disable all plugins.
|
||||||
if (pluginManager != null) pluginManager.disablePlugins();
|
if (pluginManager != null) pluginManager.disablePlugins();
|
||||||
// Shutdown the game server.
|
// Shutdown the game server.
|
||||||
@ -200,14 +203,14 @@ public final class Grasscutter {
|
|||||||
// Wait for Grasscutter's thread pool to finish.
|
// Wait for Grasscutter's thread pool to finish.
|
||||||
var executor = Grasscutter.getThreadPool();
|
var executor = Grasscutter.getThreadPool();
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
if (!executor.awaitTermination(5, TimeUnit.SECONDS)) {
|
if (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
|
||||||
executor.shutdownNow();
|
executor.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for database operations to finish.
|
// Wait for database operations to finish.
|
||||||
var dbExecutor = DatabaseHelper.getEventExecutor();
|
var dbExecutor = DatabaseHelper.getEventExecutor();
|
||||||
dbExecutor.shutdown();
|
dbExecutor.shutdown();
|
||||||
if (!dbExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
|
if (!dbExecutor.awaitTermination(2, TimeUnit.MINUTES)) {
|
||||||
dbExecutor.shutdownNow();
|
dbExecutor.shutdownNow();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
Loading…
Reference in New Issue
Block a user