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

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of Stuntbros101 Stuntbros101 Nov 02, 2014 at 19:40 UTC - 0 likes

    I set up everything right, but when in the chat it says, "Server is restarting we will be back soon!" my server never restarts...

  • Avatar of Standfford Standfford Sep 09, 2014 at 22:01 UTC - 0 likes

    I have error when server is restarting:

    [10:59:01] [Timer-5/WARN]: Exception in thread "Timer-5" [10:59:01] [Timer-5/WARN]: java.lang.IllegalStateException: Asynchronous player kick! [10:59:01] [Timer-5/WARN]: at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) [10:59:01] [Timer-5/WARN]: at org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer.kickPlayer(CraftPlayer.java:241) [10:59:01] [Timer-5/WARN]: at com.hamaluik.SimpleRestart.SimpleRestart.clearServer(SimpleRestart.java:257) [10:59:01] [Timer-5/WARN]: at com.hamaluik.SimpleRestart.SimpleRestart.stopServer(SimpleRestart.java:270) [10:59:01] [Timer-5/WARN]: at com.hamaluik.SimpleRestart.SimpleRestart$2.run(SimpleRestart.java:242) [10:59:01] [Timer-5/WARN]: at java.util.TimerThread.mainLoop(Unknown Source) [10:59:01] [Timer-5/WARN]: at java.util.TimerThread.run(Unknown Source)

  • Avatar of fujiboy4 fujiboy4 Aug 20, 2014 at 23:57 UTC - 0 likes

    Can u make this plugin actually restart the server instead of stopping?

  • Avatar of unquieterpig unquieterpig Aug 17, 2014 at 23:44 UTC - 0 likes

    Is there anyway to get the source code of this plugin? Or the creator just abandoned it completely?

    BFAK:90636457,19082f1f0b0132c034a09d33265cf462f907d692234c876081de6f7fa2b38945

  • Avatar of greendroid10 greendroid10 Jul 23, 2014 at 11:42 UTC - 0 likes

    My experience is that it works fine during the day then the next morning I look at my server and it says stopped and it doesn't restart it. I use multicraft on mcprohost.

  • Avatar of cc123lol cc123lol May 24, 2014 at 00:02 UTC - 0 likes

    Can someone please tell me how to use this on multicraft?

    MCCC

  • Avatar of lenis0012 lenis0012 May 02, 2014 at 11:58 UTC - 0 likes

    @jaspersmienk: Go

    If you are using a hsot there is no startup script being used.
    SO thia does not work with hosts often.

    But multictaft automaticly restarts servers wehn they go down, unless you stop it through the control panel.

  • Avatar of trev0 trev0 Mar 10, 2014 at 19:15 UTC - 0 likes

    @dragonkit545: Go

    if craftbukkit works on mac then this should too

  • Avatar of dragonkit545 dragonkit545 Feb 19, 2014 at 22:34 UTC - 0 likes

    Does this work for Mac?

Facts

Date created
Feb 02, 2012
Categories
Last update
Aug 25, 2012
Development stage
Release
Language
  • enUS
License
Public Domain
Curse link
SimpleRestart
Downloads
42,589
Recent files

Authors