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 update to 1.5.1
This seems like a good plugin, but could you/someone post a video on how to do this? Because I just get a bunch of messages saying "Could not find the path specified" Thanks.
-phades99
@Cigy111
We use centos, What i do is use 2 scripts, (could be one, but we have other things going on) one is startserv this simple if exist checks a file called kill, if exists then delete that file and bail, otherwise start servrun and bail.
servrun starts the server then hangs, this is where we put all the stuff we need execueted for the server to run. on server bail it simply calls startserv and it loops.
This gives us 2 levels of operation and we can sigHUP the server so it does "softstart" using the same memory map or allows to fork or suspend the process.
if you're not that technical quote me and ill give examples, but its really simple.
if in doubt, just make the last line of your stat script the name of your start script and dont put a & on the end.
Anyone help to get this to work on linx centos i can't seem to get it to work the right way
Yahh this plugin works with tekkit even with the newest version!!!
@silentsam55
your script is breaking its loop. paste your script (use a code tag or pastebin) and what OS you using?
I'm having an issue with this plugin too. it does everything except the actual restart .. UNLESS an op is online.
Like one out of twenty times, it will only stop the server, and not restart it. Anyone know why? Is it some conflicting plugins maybe? Or just a glitch?
@imaapseudonym
If you are using a host you would have to send them the link to this page and ask them to set it up. They may or may not approve but its worth a shot.
Plugin needs updated sometimes it works sometimes it dosnt
Can you use this on rented servers? I am thinking not because the script isn't available for us to edit I don't think.
Does this work with the newest minecraft and bukkit? :/ So that's bukkit ver 1.4.7-r1.0 and minecraft 1.4.7?
Also is it not as easy as just adding the downloaded file to the plugins folder? :/ Why does the run/bat file need to be edited? Can you not just have it auto change it after you launch the server? Like auto add like what worldgard and worldedit does? They auto add the files to make it work...so can't simple restart be changed to auto-reconfig/add the files/folders to the bukkit server? When launched for the first time..? :/ And if so why has this not yet been done? It'd be a lot easyer to add to a server then having to add a folder and edit the .bat run file...
How would I make this work if I'm using FTP? I'm fairly new to it and I would really like this plugin. It'd help greatly.
Any help is much appreciated!
Thanks!
-Lazor
This is great! Helps keep my server fresh and running smoothly. I have set to restart every 6 hours (4 times a day). It really helps with lag and can happen without me needing to think about it! Thanks! :D
It looks like the reason that this plugin doesn't kick players is because it uses a separate thread for timed restarts, but allows the main thread to do instant restarts, and the methods it uses to trigger the shutdown should only be used from the main thread. It would be an easy fix to make it schedule the command to be run on the main thread, rather than incorrectly running it from another thread. If I get a chance, I'll go ahead and do this later, but if not, hopefully someone will see this and know how to fix it.
When ever the restart time goes up it kicks players off but then it doesn't restart
@craftovski
have the same problem
This'll work for macs?!
Just to let everyone know, this plugin works great on 1.4.7-R0.1. I just dropped it in the plugins folder, edited the config to what I needed and it works.
@mysticmagicuser :start java -Xmx3G -Xms2G -jar craftbukkit.jar nogui pause goto start
what this will do is on you stop the server with /stop it will stop and then start up
Hi, how shall i edit my RUN.bat, I use:
java -Xmx3G -Xms2G -jar craftbukkit.jar nogui pause
For startup file, if I try to replace that with what u have on this site i get: The system cant......
What do I need to do?