Spigot added a feature allowing for server to automatically restart on crashes,
as well as when authorized user executes /restart
command.
When server starts to shut down, it spawns a new process which runs your restart script,
as specified in spigot.yml
under settings.restart-script
, which defaults to ./start.sh
.
The idea is that the original server will stop completely, and the new instance will take its place.
Because the new server is created before old one fully stopped, this means:
- You need enough spare resources, to temporarily run 2 servers at the same time, as the old instance haven't freed up CPU/RAM while the new one starts and prepares itself.
- You might hit
Unable to bind to port
errors, because old server is still occupying the port. - You might hit
Is another instance running
error, mentioning thatworld/session.lock
is in use
Because the new server is being detached, that means that if you use tmux
or screen
to start your server,
it no longer will give you access to server console after restart.
The solution is simple - don't let the restart script start any server, but instead have it communicate with your start script that when old instance is shut down, it should start a new one instead.
The easiest way is to simply create 2 scripts - start.bat
which will be the start script,
and restart.bat
which will be used by Spigot to notify that a restart is needed.
First, configure spigot.yml
to use your restart script instead:
settings:
restart-script: restart.bat
Finally, copy the attached to this gist start.bat
and restart.bat
scripts
and place them in your server folder from where you start it,
which usually is the same directory where server jar, settings and worlds are in.
Make sure to understand what they do and change memory setting and other flags to your liking.
Now you can start your server by running start.bat
. That's it!
You can find Bash version of this script here
If you have questions, its best to ask them here so others can see.
Alternatively, reach me over on Discord pie#1308
.
It can appear on restart if you forgot to remove ./
in start of your restart-script
in spigot.yml
Solutions:
- Change
./restart.bat
torestart.bat
inspigot.yml