Skip to content

Configurable shutdown and restart process#8152

Closed
Lulu13022002 wants to merge 2 commits into
PaperMC:masterfrom
Lulu13022002:feat/shutdown
Closed

Configurable shutdown and restart process#8152
Lulu13022002 wants to merge 2 commits into
PaperMC:masterfrom
Lulu13022002:feat/shutdown

Conversation

@Lulu13022002
Copy link
Copy Markdown
Contributor

Closes #7446

This allow more flexibility for plugins to restart or shutdown the server with other external app:

  • Exit the process with a non zero exit code (also plugin should avoid the 70 exit code already used for watchdog)
    => server.abnormalShutdown(exitCode)

  • Restart the process without a script but using a runnable this allow plugin to do more things without adding a new shutdown hook. Also plugin can easier choose the right executing order
    => server.restart(() ->...)

Keep in mind that theses functions must be called on the main thread (to avoid background process, data loss and file lock).

Also i have added a new config option: predictShellOnRestart (true by default)
By default when server restart spigot predict which shell will be used for windows and "others" but this behavior can cause some trouble in container or when the predicted shell is not available for X reason

@Lulu13022002 Lulu13022002 requested a review from a team as a code owner July 17, 2022 16:41
@Owen1212055
Copy link
Copy Markdown
Member

Keep in mind that theses functions must be called on the main thread (to avoid background process, data loss and file lock).

Perhaps then this should be documented?

And if we don't want plugins using the watchdog exit code, perhaps log when a plugin does this? See StackWalkerUtil to get the caller plugin

Comment on lines +98 to +105
+ // Paper - extract method and cleanup
+ addRawShutdownHook(onExit);
+ System.out.println("Attempting to restart with a plugin custom hook");
+ // Stop the watchdog
+ WatchdogThread.doStop();
+
+ shutdownServer(true);
+ // Paper end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove a sysout here, also paper comments inside paper comments

+ public boolean lagCompensateBlockBreaking = true;
+ public boolean useDimensionTypeForCustomSpawners = false;
+ public boolean strictAdvancementDimensionCheck = false;
+ public boolean predictShellOnRestart = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether it might be nice to have a system property for this instead of an option so that it can be set by hosts, though I doubt many of them use the restart command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Expose abnormal exit path to plugins.

4 participants