SimpleRestart
SimpleRestart
Version 1.3.4 by FuzzyWuzzie and THExSYSTEM
Source
The source of this plugin can be found on GitHub:
Description
SimpleRestart is a plugin for Bukkit (a Minecraft server wrapper) which allows server operators to simply and easily restart their server, as well as schedule automatic restarts of the server "for freshness". The plugin contains flexible yet straightforward commands, is easy to set up and use, and makes use of Permissions.
Setting Up
Simply copy SimpleRestart.jar and the SimpleRestart folder into the "plugins" subdirectory of your minecraft server. If you do not copy in the SimpleRestart folder, it will be created for you automatically, along with a default configuration file. Edit the configuration file (config.yml) as you see fit, then modify your server startup script so that it automatically reboots the server when it gets "/stop"ped.
The Configuration File
The default configuration file is mostly straight forward and contains numerous comments. However, each option is detailed below:
- auto-restart: enable / disable automatic, time-scheduled restarting. If this is set to "no" then the server will only ever restart when using the "/restart" command.
- auto-restart-interval: this is how often (in hours) the server will automatically restart itself (only if auto-restart is set to "yes")
- warn-times: Before the server restarts, it will send out a friendly warning to all connected players, this setting is a list that describes the amount of time (in minutes) before the server automatically reboots that players are warning. For example: warn-times: [10, 5, 2, 1] will warn players at 10 minutes, 5 minutes, 2 minutes, and 1 minute before the server reboots.
- warning-message: this is the message that will be displayed as a warning that the server will be restarting soon. You may use classic minecraft server colour codes (http://www.minecraftwiki.net/wiki/Classic_server_protocol#Color_Codes) and "%t"% to indicate how long before the server reboots. For example: warning-message: "&cServer will be restarting in %t minutes!" will display "Server will be restarting in 5 minutes!" in red (with warn-time = 5)
- restart-message: this is the message that players will see when they are kicked from the server due to the automatic reboot. Again, color codes can be used here.
Editing Your Startup Script
In order for this plugin to work properly, you will have to make a slight modification to your startup script (craftbukkit.bat on windows, craftbukkit.sh on Linux). This plugin works by simply scheduling regular "stops" of the server. Then when the server goes down, the startup script simply loops around and starts the server up again, with minimal mumbo-jumbo.
To differ between a real "/stop" and just a "/restart" you have to check the modification time of the file SimpleRestart/restart.txt in your plugins directory. If a real "/stop" was called then the modification time of the file remains the same. Otherwise, if just a "/restart" was called, the modification time will be changed. There is a helper script für *nix OSes which implements this: simple_restart_helper.sh
This is accomplished in the startup scripts using infinite loops:
- For Windows, put ":start" on the line before what you want repeated, then "goto start" on the line after what you want repeated to make an infinite loop. Example craftbukkit.bat:
@ECHO OFF SET BINDIR=%~dp0 CD /D "%BINDIR%" :start "%ProgramFiles%\Java\jre6\bin\java.exe" -Xmx1024M -Xms1024M -jar craftbukkit.jar goto start
- For *nix OSes, put "while true" <new line> "do" on the lines before what you want repeated, and "done" on the line after to make an infinite loop. Example craftbukkit.sh:
#!/bin/sh BINDIR=$(dirname "$(readlink -fn "$0")") cd "\$BINDIR" while true do java -Xmx1024M -Xms1024M -jar craftbukkit.jar echo "If you want to completely stop the server process now, press Ctrl+C before the time is up!" echo "Rebooting in:" for i in 5 4 3 2 1 do echo "$i..." sleep 1 done echo "Rebooting now!" done
On Windows, to exit this infinite loop (i.e., take the server down for good), simply close the command window. On Linux, stop the server then press "Ctrl+C" to cancel the process.
Permissions Nodes
The following permissions can be configured:
- simplerestart.restart to use just about anything in the /restart or /reboot commands, users must have the permission
- simplerestart.time to use the /restart time command, users must have the permission
- simplerestart.memory to use the /memory command, users must have the permission
- Note: simplerestart.* shouldn't work
Commands
All commands may be typed in the console (without the "/" of course) or by players in-game:
- /restart help: gives a simple help menu
- /restart now: restarts the server immediately
- /restart time: informs you how much time is left before the server restarts
- /restart (h|m|s) <time>: turns automatic restarting on (if it was off) and reschedules the next automatic restart to be <time> (hours, minutes, or seconds) away from now. For example, to reboot the server in 15 minutes, use "/restart m 15". 'h' is for hours, 'm' is for minutes, and 's' is for seconds.
- /restart on: turns automatic restarting on (if disabled in configuration OR via commands. Will start the scheduler from the current time based on the settings in the configuration.
- /restart off: cancels any pending automatic restarts and prevents automatic restarts from happening until re-enabled
- /memory: displays the java runtime memory usage, useful for catching runaway plugins
Changelog
- 1.3.4 Updated to Bukkit v1.3.1-R2.0
- 1.3.3 Updated to Bukkit v1.2.4-R1.0
- 1.3.2 Updated to Bukkit v1.2.3-R0.1
- 1.3.1 Updated to Bukkit v1.1-R6. Added support for bPermissions and PermissionsEx.
- 1.3.0 Updated to Bukkit v1.1-R1
- 1.2.0 Changed the scheduling system from Bukkit's internal scheduler (which gets delayed in the event of lag) to Java timers, which should be server lag-proof.
- 1.1.0 Added multiple warnings and tidied up code a bit
- 1.0.1 Added forced auto-save before reboot and separate permissions node for checking how long before restart
- 1.0.0 Initial release
Please compile with 1.4.2? So I have the peace of mind that it's compatible and that this plugin is still in active development...
I use bukkitGUI as a server manager and BukkitGUI does not have a craftbukkit.bat. How to make it so it restarts? currently the server only shuts down but not start up.
I always get this message: Something went wrong while saving & stoping!
Is that plugin can prevent server in 100% from not starting after stop?
Cuz acctually im using my own .ssh script with crontab and sometimes after stop command my server wont start again cuz idk why but stopping the server freezing in weird moment after 60 seconds command for start is sennding and then nothing happend, after that only solution is to kill screen.
So an auto restart was supposed to happen, but instead I got this:
2012-10-19 10:38:48 [WARNING] Could not properly handle event PLAYER_KICK: java.lang.IllegalAccessError: Synchronized code got accessed from another thread: java.util.TimerThread at org.bukkit.event.Listener.onPlayerKick(Listener:0) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:339) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462) at net.minecraft.server.NetServerHandler.disconnect(NetServerHandler.java:143) at net.minecraftserverhook.NetServerHandlerProxy.disconnect(NetServerHandlerProxy.java:64) at org.bukkit.craftbukkit.entity.CraftPlayer.kickPlayer(CraftPlayer.java:216) at com.hamaluik.SimpleRestart.SimpleRestart.clearServer(SimpleRestart.java:257) at com.hamaluik.SimpleRestart.SimpleRestart.stopServer(SimpleRestart.java:270) at com.hamaluik.SimpleRestart.SimpleRestart$2.run(SimpleRestart.java:242) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) 2012-10-19 10:38:48 [INFO] This error is logged only once: it could have occurred multiple times by now. 2012-10-19 10:38:48 [INFO] Please contact one of the authors of plugin 'SimpleRestart': FuzzyWuzzie, THExSYSTEM 2012-10-19 10:38:48 [INFO] [mcjobs] Saving 12345gabbe12345 file 2012-10-19 10:38:48 [WARNING] Could not properly handle event PLAYER_QUIT: java.lang.IllegalAccessError: Synchronized code got accessed from another thread: java.util.TimerThread at org.bukkit.event.Listener.onPlayerQuit(Listener:0) at sun.reflect.GeneratedMethodAccessor493.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:339) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462) at net.minecraft.server.ServerConfigurationManagerAbstract.disconnect(ServerConfigurationManagerAbstract.java:206) at net.minecraft.server.NetServerHandler.disconnect(NetServerHandler.java:165) at net.minecraftserverhook.NetServerHandlerProxy.disconnect(NetServerHandlerProxy.java:64) at org.bukkit.craftbukkit.entity.CraftPlayer.kickPlayer(CraftPlayer.java:216) at com.hamaluik.SimpleRestart.SimpleRestart.clearServer(SimpleRestart.java:257) at com.hamaluik.SimpleRestart.SimpleRestart.stopServer(SimpleRestart.java:270) at com.hamaluik.SimpleRestart.SimpleRestart$2.run(SimpleRestart.java:242) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) 2012-10-19 10:38:48 [INFO] This error is logged only once: it could have occurred multiple times by now. 2012-10-19 10:38:48 [INFO] Please contact one of the authors of plugin 'SimpleRestart': FuzzyWuzzie, THExSYSTEM
Anyone know of a way to force the map to NOT get saved during the reboot?
@Gunnerrrrr
lol request...
Please add a feature to make a custom message for each time you restart.
EX: /restart now Quick Reboot
then later do /restart now Rebooting again
Without having to modify the config, especially since you have to restart to apply it...
another problem, sometimes it just reloads and doesn't restart
guys i am trying to get this updated. can u please support me in the forums. http://forums.bukkit.org/threads/will-someone-please-update-simplerestart-automatic-server-rebooting.103723/
@TheVoxelBox
I have the same problem. Sometimes it works, but sometimes this plugin only kicks all player but does not restart the server after it.
The plugin is only kicking everyone and then counting in reverse instead of restarting. No errors are thrown. Latest dev Bukkit used, WIn7x64.
Please update! Or someone that knows how to code please fix the time counting backwards after server restart!
Would there be a way to not have it show the decimal for the minute warnings? I have a 5 4 3 2 1 warning and each time it says 5.0 minutes, etc. Anyway to change this?
@craftovski
THIS SAME PROBLEM!!! Please help
@craftovski
Yea, mine just did this.
@thexsystem
Any date on a fix for this?
2012-09-08 21:06:15 [INFO] [SimpleRestart] Enabling SimpleRestart v1.3.4 2012-09-08 21:06:15 [INFO] [SimpleRestart] permissions (PermissionsEx-Plugin) successfully loaded 2012-09-08 21:06:15 [SEVERE] Error occurred while enabling SimpleRestart v1.3.4 (Is it up to date?) java.lang.NullPointerException at com.hamaluik.SimpleRestart.SimpleRestart.onEnable(SimpleRestart.java:60) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:374) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:283) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:265) at net.minecraft.server.MinecraftServer.i(MinecraftServer.java:297) at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:276) at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:226) at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:140) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:379) at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
Looks like if a plugin throws an error when shutting down the server will remain shut down and not restart.
@thexsystem: Sometimes (30% of the time) server dont restart properly cause of some bug or when someone was executing some command while server was kicking players and restarting, and when server doesnt restart properly it only kicks players and doesnt complete full stop - start and plugins dont reload so SimpleRestart counts in negativ (-1h2m2s) so im asking you if u can make simple restart Check IF count is in Negative and IF it is do another restart cause this way server will eventually restart properly and it will be all good.
Consider it and reply if u need to tell/ask me something or idk.
Ty.
this plugin is so good! thank you for this! keep it up