Just looking for a correction/addition to this cannibalized restart code for (originally a Minecraft server, though that is not what it's used for now).
@echo off
title Server Restarter
color 0A
cls
@%SystemRoot%\system32\ping.exe -n 1 xxx.xxx.x.xx
pause
:start
Call Server.bat
cls
pause
This currently does a very simple job: calls server.bat
and starts the server. It has none of the bells and whistles I'd like it to have though.
The output of ping is not functional at the moment.
The goal:
Ping to see if a specific IP (and maybe ports) are reachable.
If they are not reachable, close any current instances of Server.exe
Continue pinging until specific IP is reachable.
Once the IP is reachable, call
server.bat
It needs to ping at intervals of ~30 seconds.
Some context for why it's needed:
The game server does not currently close its process regardless of it being online or not, it continues to run in the process window. That's why I need it close any current instances, else we just end up with multiples of the same server running.
The server is run from a local computer using direct IP connection, therefore if the local computer isn't connected to the internet, the server wont be reachable to anyone (obviously). The intent for the .bat
is to run continuously so even when the user isn't at the computer, it will take care of ensuring the server is online 24/7.
This will be a file I will want to make available to other server hosts who may want to use it to keep themselves online 24/7.
The port check will be to ensure the master server ports are reachable and the fault is/isn't on their side, this is not essential so if it's too much trouble, don't worry.
Inside "Server.bat":
@echo off
echo Server process starting
echo Ctrl+Alt+Del to Kill
Server.exe -batchmode -nographics
All of your assistance and comments are very much welcomed. I tried to generalize this as much as possible to keep it simple, so it can be altered for anyone else who may find use for it with any application.