Paper: /restart no longer working.

Created on 11 Oct 2018  路  13Comments  路  Source: PaperMC/Paper

What behaviour is expected:

Server to shut down and start its self again.

What behaviour is observed:

Server shuts down and does not re start.

Steps/models to reproduce:

Issue /restart from in game or restart from console

Plugin list:

Paper build number:

Anything else:

Also does not restart on crash.

No changes were made to my start scripts. I believe /restart worked properly on the previous paper version. Was definitely working on versions prior to the last.

Server OS is Ubuntu 18.04

spigot.yml

# This is the main configuration file for Spigot.
# As you can see, there's tons to configure. Some options may impact gameplay, so use
# with caution, and make sure you know what each option does before configuring.
# For a reference for any variable inside this file, check out the Spigot wiki at
# http://www.spigotmc.org/wiki/spigot-configuration/
# 
# If you need help with the configuration or have any questions related to Spigot,
# join us at the IRC or drop by our forums and leave a post.
# 
# IRC: #spigot @ irc.spi.gt ( http://www.spigotmc.org/pages/irc/ )
# Forums: http://www.spigotmc.org/

config-version: 11
settings:
  save-user-cache-on-stop-only: false
  sample-count: 12
  user-cache-size: 1000
  moved-wrongly-threshold: 0.0625
  moved-too-quickly-multiplier: 1000.0
  bungeecord: false
  late-bind: false
  player-shuffle: 0
  timeout-time: 60
  restart-on-crash: true
  restart-script: ./start.sh
  netty-threads: 4
  attribute:
    maxHealth:
      max: 2048.0
    movementSpeed:
      max: 2048.0
    attackDamage:
      max: 2048.0
  debug: false
messages:
  whitelist: You are not whitelisted on this server!
  unknown-command: Unknown command. Type "/help" for help.
  server-full: The server is full!
  outdated-client: Outdated client! Please use {0}
  outdated-server: Outdated server! I'm still on {0}
  restart: Server is restarting. BRB!
stats:
  disable-saving: false
  forced-stats: {}
advancements:
  disable-saving: false
  disabled:
  - minecraft:story/disabled
commands:
  spam-exclusions:
  - /skill
  silent-commandblock-console: false
  replace-commands:
  - setblock
  - summon
  - testforblock
  - tellraw
  tab-complete: 0
  send-namespaced: true
  log: true
world-settings:
  default:
    verbose: true
    mob-spawn-range: 3
    entity-activation-range:
      animals: 12
      monsters: 20
      misc: 3
      water: 16
      tick-inactive-villagers: true
    entity-tracking-range:
      players: 48
      animals: 48
      monsters: 48
      misc: 32
      other: 64
    ticks-per:
      hopper-transfer: 8
      hopper-check: 1
    hopper-amount: 1
    random-light-updates: false
    dragon-death-sound-radius: 0
    seed-village: 10387312
    seed-desert: 14357617
    seed-igloo: 14357618
    seed-jungle: 14357619
    seed-swamp: 14357620
    seed-monument: 10387313
    seed-shipwreck: 165745295
    seed-ocean: 14357621
    seed-slime: 987234911
    hunger:
      jump-walk-exhaustion: 0.05
      jump-sprint-exhaustion: 0.2
      combat-exhaustion: 0.1
      regen-exhaustion: 6.0
      swim-multiplier: 0.01
      sprint-multiplier: 0.1
      other-multiplier: 0.0
    max-tnt-per-tick: 100
    max-tick-time:
      tile: 1000
      entity: 1000
    squid-spawn-range:
      min: 45.0
    growth:
      cactus-modifier: 100
      cane-modifier: 100
      melon-modifier: 100
      mushroom-modifier: 100
      pumpkin-modifier: 100
      sapling-modifier: 100
      wheat-modifier: 100
      netherwart-modifier: 100
      vine-modifier: 100
      cocoa-modifier: 100
    merge-radius:
      exp: 6
      item: 4
    enable-zombie-pigmen-portal-spawns: true
    item-despawn-rate: 6000
    wither-spawn-sound-radius: 0
    arrow-despawn-rate: 600
    view-distance: 6
    hanging-tick-frequency: 100
    zombie-aggressive-towards-villager: true
    nerf-spawner-mobs: false
    max-entity-collisions: 8

start.sh

#!/bin/bash

screen -dmS Minecraft-Server /home/redacted/Minecraft-Server/wrapper.sh

wrapper.sh

#!/bin/bash
cd ~/Minecraft-Server;

java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar paperclip.jar

log snippet

> restart
[21:17:56 INFO]: Attempting to restart with ./start.sh
[21:17:56 INFO]: Redacted lost connection: Server is restarting. BRB!
[21:17:56 INFO]: Redacted  left the game
[21:17:57 INFO]: Stopping server
[21:17:57 INFO]: [SuperVanish] Disabling SuperVanish v6.1.0
[21:17:57 INFO]: [mcMMOAction] Disabling mcMMOAction v2.4-SNAPSHOT
[21:17:57 INFO]: [Dynmap-GriefPrevention] Disabling Dynmap-GriefPrevention v0.80
[21:17:57 INFO]: [VaultChatFormatter] Disabling VaultChatFormatter v1.0-SNAPSHOT
[21:17:57 INFO]: [DiscordSRV] Disabling DiscordSRV v1.16.4
[21:17:57 INFO]: [DiscordSRV] Saved linked accounts in 8ms
[21:17:57 INFO]: [DiscordSRV] Saved metrics in 1ms
[21:17:57 INFO]: [DiscordSRV] Shutdown completed in 128ms
[21:17:57 INFO]: [McMMOExtras] Disabling McMMOExtras v5.5
[21:17:57 INFO]: [ProtocolLib] Disabling ProtocolLib v4.4.0
[21:17:57 INFO]: [SimpleSit] Disabling SimpleSit v1.6.3
[21:17:57 INFO]: [GriefPrevention] Disabling GriefPrevention v16.9
[21:17:57 INFO]: [GriefPrevention] GriefPrevention disabled.
[21:17:57 INFO]: [Vault] Disabling Vault v1.7.1-b${env.TRAVIS_BUILD_NUMBER}
[21:17:57 INFO]: [mcMMO] Disabling mcMMO v1.6.0-SNAPSHOT
[21:17:57 INFO]: [LagMonitor] Disabling LagMonitor v1.17.1-SNAPSHOT
[21:17:57 INFO]: [InstantDecay] Disabling InstantDecay v1.4.2
[21:17:57 INFO]: [HomeSpawn] Disabling HomeSpawn v1.0
[21:17:57 INFO]: [VeinMiner] Disabling VeinMiner v1.12.0
[21:17:57 INFO]: [VeinMiner] Clearing localized data
[21:17:57 INFO]: [dynmap] Disabling dynmap v3.0-beta-1-129
[21:17:57 INFO]: [dynmap] Unloaded 11 components.
[21:17:57 INFO]: [dynmap] Stopping map renderer...
[21:17:58 INFO]: [dynmap] Disabled
[21:17:58 INFO]: [LuckPerms] Disabling LuckPerms v4.2.99
[21:17:58 INFO]: [LuckPerms] Closing storage...
[21:17:58 INFO]: [LuckPerms] Shutting down internal scheduler...
[21:17:58 INFO]: [LuckPerms] Goodbye!
[21:17:58 INFO]: Saving players
[21:17:58 INFO]: Saving worlds
[21:17:58 INFO]: Saving chunks for level 'world'/minecraft:overworld
[21:17:58 INFO]: Saving chunks for level 'world_nether'/minecraft:the_nether
[21:17:58 INFO]: Saving chunks for level 'world_the_end'/minecraft:the_end
>

Most helpful comment

Thank you for your solution. I have one more question if you don't mind. I have autorestart plugin on my server, which restarts server periodically. So if this plugin restart server will such script conflict with it?

Im not sure, i use a cronjob to send /stop to my server every day at 4:55am.

in etc/crontab
55 4 * * * root su username -c "bash /home/username/Minecraft-Server/restart.sh"

restart.sh
*********

!/bin/bash

var=0
var2=5
while true
do
if [[ $var -le 4 ]]; then
echo "say Daily restart in $var2 minutes"
screen -S Minecraft-Server -X stuff "^Msay Daily restart in $var2 minutes^M^M"
elif [[ $var -gt 4 ]]; then
echo "say Restarting Now!"
screen -S Minecraft-Server -X stuff "^Msay Restarting Now!^M^M"
sleep 10s
echo "stop Daily restart! Server will be back up in a moment"
screen -S Minecraft-Server -X stuff "^Mstop^M^M"
exit
fi
var=$((var+1))
var2=$((var2-1))
sleep 60s
done
*********
starting at 4:55 it starts counting down every minute then when it hits 5 it waits 10 seconds and sends /stop

All 13 comments

[21:17:56 INFO]: Attempting to restart with ./start.sh
means that paper has hooked in and set everything up needed to restart properly from our end, if it's failing to start, that means that the issue is going to be with your script or startup of the new server failing

I don't recommend the usage of restart, personally, the setup is somewhat flawed in that it's always possible that your server starts up before the existing instance has closed fully, at bare minimum you should have late-bind enabled, but I really just suggest making your start scripts automatically loop as opposed to relying on this mechanism

Alright, thanks for the response.

As i stated above, i made no changes to my start scripts, All of the scripts run fine if run manually, its an issue with the minecraft server its self. So i don't understand why this functionality has worked great for months and now it doesn't, but alright. ill look into enabling late bind also, i just usually don't have players trying to rejoin that early.

Also ill try this for a new script then, If there is no pid for for the file it will run the script.

#!/bin/bash

echo "Press CTRL+C to stop..."
trap "exit" INT
while true
do
    _pid="$(lsof -t /home/Redacted/Minecraft-Server/paperclip.jar)"
    if [ -z "$_pid" ] 
    then
        screen -wipe
        screen -dmS Minecraft-Server /home/Redacted/Minecraft-Server/wrapper.sh
    else
        sleep 1 
    fi  

done

The problem is that the new server starts up before the java process has fully closed, a common issue I had with the restart script, even with late-bind, was that the server would start up too fast and attempt to bind onto the network, and fail because the existing server was still running attempting to shut down

All it takes is for something to delay the work of fully closing java for it to break, hence why I don't recommend it for usage anymore

Ah i see, that made it click for me, i didn't even think about the port still being in use when the new instance tries to start up. I guess its a good thing it fails this way instead of it potentially having multiple instances running and waiting for the port, taking up resources.

Thank you.

Can you help me out here? What should I do to make /restart command working? I have linux server and launching server via this start.sh:

screen -dmS "minecraft_server" sudo java -Xmx1024M -Xms1024M -jar spigot-1.14.1.jar

When I try to restart it just stops, but never starts.
I also tried this:

#!/bin/sh
sleep 10
while true
do
sudo screen -dmS "minecraft_server" sudo java -Xmx1024M -Xms1024M -jar spigot-1.14.1.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

oooops. It's not about spigot lol. but mb you will help me anyway :)

oooops. It's not about spigot lol. but mb you will help me anyway :)

This is what i use. I dont use /restart. I use /stop and my script automatically starts it again after 15 seconds.

In etc/rc.local i have this to start my loop script at system startup.
su username -c "screen -dmS Mcloop /home/username/Minecraft-Server/MinecraftStartLoop.sh"

Next is the script that runs in a loop checking to see if paperclip.jar is running, if its not it waits 15 seconds, makes a beep, and starts the server. This script can be paused by pressing any key, so you can do /stop and upload updated files without it trying to restart, then when your ready you can just push any key again and in 15 seconds it will start paperclip.jar

MincraftStartLoop.sh
( having trouble getting all of this in a codeblock. So its everything between the **)
********************

!/bin/bash

echo "Press CTRL+C to stop..."
trap "exit" INT

running=true
runmsg=true
pmsg=true
pmsg2=true

while true
do
if [[ "$running" == "true" ]]; then
if [[ "$pmsg2" == "true" ]]; then
echo $(date '+%Y-%m-%d--%H-%M-%S-')"loop running!"
pmsg2=false
fi

    _pid="$(lsof -t /home/username/Minecraft-Server/paperclip.jar)"
    if [ -z "$_pid" ] 
    then
        echo $(date '+%Y-%m-%d--%H-%M-%S-')"paperclip.jar Pid Not Found, Starting! (15 secs)"
        sleep 15 
        beep -f 5000 -l 1000
        screen -dmS Minecraft-Server /home/username/Minecraft-Server/wrapper.sh
        sleep 10
        runmsg=true
    else
        if [[ "$runmsg" == "true" ]]; then
            echo $(date '+%Y-%m-%d--%H-%M-%S-') "paperclip.jar Pid is running!"
            runmsg=false
        fi
    fi
    pmsg=true
else
    beep -f 1000 -l 1000
    if [[ "$pmsg" == "true" ]]; then
        echo $(date '+%Y-%m-%d--%H-%M-%S-')"loop paused!"
        pmsg=false
        pmsg2=true

    fi
fi

if read -sn 1 -t 0.25; then
    if [[ "$running" == "true" ]]; then
        running=false
    else 
        running=true
    fi
fi

done

******************

When the script needs to start the server, it runs wrapper.sh. I only have it sperated so i can start the server with a single script while testing.

wrapper.sh
*******

!/bin/bash

cd ~/Minecraft-Server;

java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar paperclip.jar
**********

Thank you for your solution. I have one more question if you don't mind. I have autorestart plugin on my server, which restarts server periodically. So if this plugin restart server will such script conflict with it?

Thank you for your solution. I have one more question if you don't mind. I have autorestart plugin on my server, which restarts server periodically. So if this plugin restart server will such script conflict with it?

Im not sure, i use a cronjob to send /stop to my server every day at 4:55am.

in etc/crontab
55 4 * * * root su username -c "bash /home/username/Minecraft-Server/restart.sh"

restart.sh
*********

!/bin/bash

var=0
var2=5
while true
do
if [[ $var -le 4 ]]; then
echo "say Daily restart in $var2 minutes"
screen -S Minecraft-Server -X stuff "^Msay Daily restart in $var2 minutes^M^M"
elif [[ $var -gt 4 ]]; then
echo "say Restarting Now!"
screen -S Minecraft-Server -X stuff "^Msay Restarting Now!^M^M"
sleep 10s
echo "stop Daily restart! Server will be back up in a moment"
screen -S Minecraft-Server -X stuff "^Mstop^M^M"
exit
fi
var=$((var+1))
var2=$((var2-1))
sleep 60s
done
*********
starting at 4:55 it starts counting down every minute then when it hits 5 it waits 10 seconds and sends /stop

Thank you. It's very helpful

BlisteringSyko, I will pay you $50 if you can help me get my cronjob running.

I used

sudo crontab -e

and then input the following:

55 20 * * * root su pi -c "bash /home/pi/minecraft/start.sh"

But I cannot get the cronjob to execut.

My start.sh script is as follows:

#!/bin/bash
export RCLONE_CONFIG=/home/pi/.config/rclone/rclone.conf
rclone sync -vv "/home/pi/minecraft" "GDrive:/MServerBackup" --local-no-check-updated --skip-links

cd /home/pi/minecraft
exec java -jar -Xms512M -Xmx2008M spigot-1.15.2.jar nogui

that start.sh file works when i call it in the terminal but not while using cronjob

BlisteringSyko, I will pay you $50 if you can help me get my cronjob running.

I used

sudo crontab -e

and then input the following:

55 20 * * * root su pi -c "bash /home/pi/minecraft/start.sh"

But I cannot get the cronjob to execut.

My start.sh script is as follows:

#!/bin/bash
export RCLONE_CONFIG=/home/pi/.config/rclone/rclone.conf
rclone sync -vv "/home/pi/minecraft" "GDrive:/MServerBackup" --local-no-check-updated --skip-links

cd /home/pi/minecraft
exec java -jar -Xms512M -Xmx2008M spigot-1.15.2.jar nogui

that start.sh file works when i call it in the terminal but not while using cronjob

I guess that will be an ez 50$ then
U need to run your script in screen or tmux.
Atleast that what i do
Create screen session - run start script in screen
Then make cron to execute inside screen

Hello, I just want to help, I post the solution I have found myself, because Internet doesn't give the best solution, spigot.yml execute with bash interpreter, and it has the time to execute only the first line, so you need to create the screen, go the directory and launch the jar in the same line (It took 3 days to me to find this solution).
This is my code for a simple start with the .sh in the same folder of my jar, my server's name is "test":

#!/bin/bash

screen -dmS test bash -c 'cd /home/minecraft/serveurs/test/ && exec -a "test" java -Xms1G -Xmx2G -jar Spigot.jar'
Was this page helpful?
0 / 5 - 0 ratings