Auto Restart

Mods
26,412 Downloads Last Updated: Jul 28, 2021 Game Version: 1.17.1

This mod restarts the Minecraft server by itself or with an external restart script.
The mod can only be used on server side and won't work on the client side.

 

You need a server to play with friends? You don't know how to set up one? Just rent an already configured server!

Click on the picture above, select a plan (with recommended at least 6 GB),
use my code agent to get 25% off your first month and enjoy playing with your friends!

 

Support

Support: Supported Minecraft Versions
New Development and Fixes: 1.17.1
Bug Fixes: 1.16.5
Critical Bug Fixes: 1.15.2
End of Support: 1.14.4, 1.16.1-1.16.4

Features

- Restarting the server at specified times
- Restarting the server with a delay, if it is empty
- Restarting the server, if the tps are below a specified level for a specified time

Server Config

The config file can be found in the "serverconfig" folder in the "world" folder and is named "auto_restart-server.toml".

- restart
  Options for restarting:
  - use_external_restart_script
    Is the server started by an external restart script?
  - restart_command
    Command that is executed on Server stopped to restart the server. Only called if "use_external_restart_script" is false.
- auto_restart
  Option for auto restarting:
  - enabled
    Should the Server do automatic restarts?
  - times
    Times in 24-hour format on which the server will automatically restart.
    Examples: "14:00", "16:32"
  - warning_times
    Times before an auto restart of the server, a restart warning should be shown.
    Examples:
      - 5s - For a message 5 seconds before a restart
      - 7m - For a message 7 minutes before a restart
      - 2h - For a message 2 hours before a restart
- on_empty_restart
  Options for restart, if the server is empty:
  - enabled
    Should the server restart, if no players are online?
  - delay
    Delay after the server should restart, if it is empty.
    Examples:
      - 5s - For a delay 5 seconds
      - 7m - For a delay 7 minutes
      - 2h - For a delay 2 hours
- low_tps_restart
  Options for restart, if the tps of server or its dimensions are low:
  - enabled
    Should the server restart, if it is below a tps level for a specified time?
  - minium_tps_level
    TPS level below which the server is restarted, if it lasts for the specified time.
  - delay
    Delay, that the server must be below the defined TPS level, in order for it to be restarted.
    Examples:
      - 5s - For a delay 5 seconds
      - 7m - For a delay 7 minutes
      - 2h - For a delay 2 hours

Commands

- /restart
  Restarts the server

How to use the Restart Mod

You can let the mod use the restart command to restart the server, or use an external restart script.
The script examples are Linux sh scripts.
You can find Windows script examples on: https://github.com/GeheimagentNr1/AutoRestart/wiki/Windows-Scripts

Restart Command

These scripts are for the use, if you have configured, that you are using an external restart script.
The first script is named "restart_start.sh". It is used to start the "restart_loop.sh" script in a screen.
bash -c 'cd <Path of your Minecraft server>; screen -d -m -S <Name of your Screen, i.e. your folders name without spaces> java -jar forge-<Minecraft version>-<Forge version>.jar'

External Restart Script

These scripts are for the use, if you have configured, that you are using an external restart script.
The first script is named "restart_start.sh". It is used to start the "restart_loop.sh" script in a screen.
bash -c 'cd <Path of your Minecraft server>; screen -d -m -S <Name of your Screen, i.e. your folders name without spaces> ./restart_loop.sh'

The "restart_loop.sh" script has the logic in it, to restart or stop the server. It will restart the server always, except in the "./auto_restart/restart" file is "0".
The Auto Restart Mod writes "-1", "0" or "1" to the file.
When the script reads the file,
- "-1" means that server crashed.
- "0" means the server was shutdown with the "/stop" command and should be stopped.
- "1" means the server that the server was stopped with the "/restart" command or an auto restart and should be restarted.

After the server was stopped for a restart, the script waits 5 seconds until it restarts the Minecraft server.
while true
do
    java -Xmx<Amount of RAM in gigatytes you want to allocate to Minecraft>G -jar forge-<Minecraft version>-<Forge version>.jar
    read -r should_restart < ./auto_restart/restart
    if [ $should_restart == "0" ]
    then
        break
    fi
    echo 'If you want to stop the server completely, press STRG-C, \before the countdown is at 1!'
    echo "Rebooting in:"
    for i in 5 4 3 2 1
    do
        echo "$i..."
        sleep 1
    done
    echo 'Server restarts!'
done

Thanks for the logo to Muse31.
You can use this mod in non-commercial modpacks without asking.
You can find more mods from me here.

Comments

  • To post a comment, please or register a new account.
Posts Quoted: