ServerRestarter is a highly configurable server restart management plugin. Through this plugin, you can set an infinite amount of messages to display and sounds to play at specific intervals. You can also enable scoreboard display (fully configurable) to inform users continuously about an oncoming restart. The /sr command is provided to trigger a restart manually or update the time until next restart and restart message. Time format in commands and config is 0d0h0m0s0ms (e.g. 3h30m, 5s500ms). Chat color format in commands and config is &code, where code is the color code.
NOTE: /restart command is currently broken, as bukkit/spigot override this command yet do not automate it; use /sr instead. NOTE: A script (listed below) is required for the restart to actually work, otherwise the server will simply shut down as usual.
This is an example configuration file (automatically generated by the plugin).
# Time before restarting the server. # Format is 0d0h0m0s0ms. restart_time: 3h kick_message: Server is restarting! Come back in a minute or two! # ServerRestarter will create this file in the base server directory # every time the plugin is enabled, and will # delete it upon being disabled given that the server is not restarting. # By not deleting it until being disabled, it guarantees that a server crash will cause a restart (as the plugin is not disabled in a crash). # This option is useful for scripts to detect if the server shut down for a restart or crash. state_file: auto_restart create_state_file: 'true' actions: # You may specify as many of these as you want. Name does not matter; value is the action. # Currently accepted formats are: # message:<time>:<message> # sound:<time>:<sound>:<volume>:<pitch> # scoreboard:<time>:enable|disable|settitle:<title>|setformat:<d|h|m|s|ms>:<text> # List of sounds can be found at http://jd.bukkit.org/rb/apidocs/org/bukkit/Sound.html. message_5m: message:5m:&aServer will restart in 5 minutes... scoreboard_5m_title: scoreboard:5m1ms:settitle:Restart Time scoreboard_5m_format: 'scoreboard:5m1ms:setformat:m:&aMinutes left:' scoreboard_5m_enable: scoreboard:5m:enable sound_5m: sound:5m:NOTE_PIANO:1.0:3.0 message_2m: message:2m:&aServer will restart in 2 minutes... message_1m: message:1m:&aServer will restart in 1 minute... sound_1m: sound:1m:NOTE_PIANO:1.0:2.0 sound2_1m: sound:1m:NOTE_BASS_GUITAR:1.0:2.0 scoreboard_1m_format: 'scoreboard:1m:setformat:s:&eSeconds left:' message_30s: message:30s:&aServer will restart in 30 seconds... sound_30s: sound:30s:NOTE_PIANO:1.0:1.0 scoreboard_30s_format: 'scoreboard:30s:setformat:s:&6Seconds left:' message_15s: message:15s:&aServer will restart in 15 seconds... sound_15s: sound:15s:NOTE_PIANO:1.0:1.0 scoreboard_15s_format: 'scoreboard:15s:setformat:s:&cSeconds left:' message_10s: message:10s:&aServer will restart in 10 seconds... sound_10s: sound:10s:NOTE_PIANO:1.0:1.0 message_5s: message:5s:&aServer will restart in 5 seconds... scoreboard_5s_format: 'scoreboard:5s:setformat:s:&4Seconds left:' sound_5s: sound:5s:NOTE_PIANO:1.0:1.0 sound_5s300ms: sound:5s300ms:NOTE_PIANO:1.0:1.0 message_4s: message:4s:&aServer will restart in 4 seconds... sound_4s: sound:4s:NOTE_PIANO:1.0:1.0 sound_4s300ms: sound:4s300ms:NOTE_PIANO:1.0:1.0 message_3s: message:3s:&aServer will restart in 3 seconds... sound_3s: sound:3s:NOTE_PIANO:1.0:1.0 sound_3s300ms: sound:3s300ms:NOTE_PIANO:1.0:1.0 message_2s: message:2s:&aServer will restart in 2 seconds... sound_2s: sound:2s:NOTE_PIANO:1.0:1.0 sound_2s300ms: sound:2s300ms:NOTE_PIANO:1.0:1.0 message_1s: message:1s:&aServer will restart in 1 second... sound_1s: sound:1s:NOTE_PIANO:1.0:1.0 sound_1s300ms: sound:1s300ms:NOTE_PIANO:1.0:1.0 sound_1s600ms: sound:1s600ms:NOTE_PIANO:1.0:1.0
More readable, alternative script (equivalent to the one above):
# Time before restarting the server. # Format is 0d0h0m0s0ms. restart_time: 3h kick_message: Server is restarting! Come back in a minute or two! # ServerRestarter will create this file in the base server directory every time the plugin is enabled, and will delete it upon being disabled given that the server is not restarting. # By not deleting it until being disabled, it guarantees that a server crash will cause a restart (as the plugin is not disabled in a crash). # This option is useful for scripts to detect if the server shut down for a restart or crash. state_file: auto_restart create_state_file: 'true' # You may specify as many of these as you want. Name does not matter; value is the action. # Currently accepted formats are: # message:<time>:<message> # sound:<time>:<sound>:<volume>:<pitch> # scoreboard:<time>:enable|disable|settitle:<title>|setformat:<d|h|m|s|ms>:<text> # List of sounds can be found at http://jd.bukkit.org/rb/apidocs/org/bukkit/Sound.html. actions: 5m_msg: 'message:5m:&aServer will restart in 5 minutes...' 5m_scb_title: 'scoreboard:5m1ms:settitle:Restart Time' 5m_scb_format: 'scoreboard:5m1ms:setformat:m:&aMinutes left:' 5m_scb_enable: 'scoreboard:5m:enable' 5m_snd: 'sound:5m:NOTE_PIANO:1.0:3.0' 2m_msg: 'message:2m:&aServer will restart in 2 minutes...' 1m_msg: 'message:1m:&aServer will restart in 1 minute...' 1m_snd: 'sound:1m:NOTE_PIANO:1.0:2.0' 1m_snd2: 'sound:1m:NOTE_BASS_GUITAR:1.0:2.0' 1m_scb_format: 'scoreboard:1m:setformat:s:&eSeconds left:' 30s_msg: 'message:30s:&aServer will restart in 30 seconds...' 30s_snd: 'sound:30s:NOTE_PIANO:1.0:1.0' 30s_scb_format: 'scoreboard:30s:setformat:s:&6Seconds left:' 15s_msg: 'message:15s:&aServer will restart in 15 seconds...' 15s_snd: 'sound:15s:NOTE_PIANO:1.0:1.0' 15s_scb_format: 'scoreboard:15s:setformat:s:&cSeconds left:' 10s_msg: 'message:10s:&aServer will restart in 10 seconds...' 10s_snd: 'sound:10s:NOTE_PIANO:1.0:1.0' 5s_msg: 'message:5s:&aServer will restart in 5 seconds...' 5s_scb_format: 'scoreboard:5s:setformat:s:&4Seconds left:' 5s_snd: 'sound:5s:NOTE_PIANO:1.0:1.0' 5s300ms_snd: 'sound:5s300ms:NOTE_PIANO:1.0:1.0' 4s_msg: 'message:4s:&aServer will restart in 4 seconds...' 4s_snd: 'sound:4s:NOTE_PIANO:1.0:1.0' 4s300ms_snd: 'sound:4s300ms:NOTE_PIANO:1.0:1.0' 3s_msg: 'message:3s:&aServer will restart in 3 seconds...' 3s_snd: 'sound:3s:NOTE_PIANO:1.0:1.0' 3s300ms_snd: 'sound:3s300ms:NOTE_PIANO:1.0:1.0' 2s_msg: 'message:2s:&aServer will restart in 2 seconds...' 2s_snd: 'sound:2s:NOTE_PIANO:1.0:1.0' 2s300ms_snd: 'sound:2s300ms:NOTE_PIANO:1.0:1.0' 1s_msg: 'message:1s:&aServer will restart in 1 second...' 1s_snd: 'sound:1s:NOTE_PIANO:1.0:1.0' 1s300ms_snd: 'sound:1s300ms:NOTE_PIANO:1.0:1.0' 1s600ms_snd: 'sound:1s600ms:NOTE_PIANO:1.0:1.0'
Linux:
#!/bin/bash JAVA="java" JAVA_OPTS="-Xms1024M -Xmx1024M" SERVER_JAR="server.jar" STATE_FILE="auto_restart" while true do $JAVA $JAVA_OPTS -jar $SERVER_JAR if [ ! -e $STATE_FILE ] then break fi echo "Restarting server in 5 seconds! Kill the process with 'ctrl+c' to prevent it from rebooting or use /stop when the server has rebooted." for i in {5..1} do echo "$i..." sleep 1 done echo "Restarting!" done
Windows: (untested- sorry, not on this OS :( let me know if it works)
@ECHO OFF SET JAVA=java SET JAVA_OPTS=-Xms1024M -Xmx1024M SET SERVER_JAR=server.jar SET STATE_FILE=auto_restart :START %JAVA% %JAVA_OPTS% -jar %SERVER_JAR% IF NOT EXIST %STATE_FILE% EXIT ECHO Restarting server in 5 seconds! Close the command prompt to prevent it from rebooting or use /stop when the server has rebooted. FOR /l %X IN (5, -1, 1) DO ( ECHO %X%... TIMEOUT 1 ) GOTO START
Alternative Windows (in case the above script does not work):
@ECHO OFF :START java -Xms1024M -Xmx1024M -jar server.jar IF NOT EXIST auto_restart EXIT GOTO START
Change the options in either script as you see fit. These will restart your server if a file named 'auto_restart' is found (configurable), otherwise exit.