Simple Server Launch Script

This simple script is designed to start your BeamMP server (if it’s not already started), validate that it is up and restart it if it’s not as well as restart it once it has hit an administrator defined uptime to stop issues with ghost cars

Install instructions:

  • Download this ZIP file
    1604080121072-beammpstartup.zip (909 Bytes)

  • Extract the ZIP file

  • Place the .bat file in your server install directory

  • Run the .bat file

Images of it running:

!1604080264908-91aacad7-4244-43a3-b217-c46aeb3b31ed-image.png

!1604080359730-ca927632-e379-436e-93f3-63cf205172c5-image.png

!1604080394100-944e7cd1-b5f1-4598-9e04-d1d7c5b2d78d-image.png

If you’re curious the full file is below:

@echo off
Set /A COUNTER=0
Set /A UPTIME=0

:load1
color 74
echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo :                    Flamers BeamMP Startup Script                   :
echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SET /P HOURS=Input number of hours before restart here:
SET "var="&for /f "delims=0123456789" %%i in ("%HOURS%") do set var=%%i
if defined var (goto :load1) else (goto :load2)

:load2
SET /P UPDATE=Input number of seconds between checks for config updates here:
SET "var="&for /f "delims=0123456789" %%i in ("%UPDATE%") do set var=%%i
if defined var (goto :load2) else (goto :run)

:run
cls
color 07
echo Loading...
ping 127.0.0.1 -n 2 > nul
echo Starting BeamMP Server
ping 127.0.0.1 -n 3 > nul
cls
goto :bau

:bau
color 74
echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo :                    Flamers BeamMP Startup Script                   :
echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto :status

:status
color 74
tasklist|find /i "BeamMP-Server.exe" >NUL
if errorlevel 1 goto :crash
if errorlevel 0 goto :timer

:crash
echo Server crashed at %time% %date%
echo Server crashed at %time% %date% >> FlamersLog.txt
goto :start

:start 
start "" BeamMP-Server.exe -e -m -v
Set /A COUNTER=0
echo Server started at %time% %date%
echo Server started at %time% %date% >> FlamersLog.txt
goto :status

:timer
ping 127.0.0.1 -n %UPDATE% > nul
echo Checking for updates...
Set /A UPTIME=UPTIME+%UPDATE%
if %UPTIME% GEQ 3600 goto:check
goto :updates

:check
Set /A UPTIME=0
Set /A COUNTER=COUNTER+1
ping 127.0.0.1 -n 1 > nul
if %COUNTER% GEQ %HOURS% goto :restart
echo Server has been up for %counter% number of hours
goto :updates

:updates
for %%i in (Server.cfg) do echo %%~ai|find "a">nul || goto :status
color 30
echo Server configuration updated, server restarting....
echo Server configuration updated at %time% %date% >> FlamersLog.txt
Set /A TIME=0
rem do workload
attrib -a Server.cfg
timeout /t 5 /nobreak
goto :restart

:restart
Set /A COUNTER=0
taskkill -im "BeamMP-Server.exe"
echo Shutting server down due to long uptime
echo Shutting server down due to long uptime at %time% %date% >> FlamersLog.txt
goto :start

Wow dude, you have been busy! Great to see people putting effort into resources and tools for their servers!

Really like this tool, but is there a simple way to shut the server down after launching with the tool?

A new day and a new version. Below are the updates to this version:

Added the ability for user defined period between checks for updated files
Added logging to file
Added logging in console
Logging enabled for restart due to long uptime
Logging enabled for restart due to crash
Enhanced visuals

New version can be found below

1604080121072-beammpstartup.zip (909 Bytes)

3 Likes

I got a bit carried away.

This new version now checks for updates to the configuration of the server every minute and restarts if there is an update

1604006749949-beammpstartupv5.zip (656 Bytes)

@echo off
Set /A COUNTER=0
Set /A TIME=0

:hours
SET /P HOURS=Input number of hours before restart here:
SET "var="&for /f "delims=0123456789" %%i in ("%HOURS%") do set var=%%i
if defined var (goto :hours) else (goto :status)

:status
tasklist|find /i "BeamMP-Server.exe" >NUL
if errorlevel 1 goto :start
if errorlevel 0 goto :timer

:start 
start "" BeamMP-Server.exe -e -m -v
Set /A COUNTER=0
goto :status

:check
if %COUNTER%==%HOURS% goto :restart
Set /A COUNTER=COUNTER+1
echo Hours up time %counter%
goto :updates

:updates
for %%i in (Server.cfg) do echo %%~ai|find "a">nul || goto :status
echo Server configuration updated, server restarting....
Set /A TIME=0
rem do workload
attrib -a Server.cfg
timeout /t 5 /nobreak
goto :restart

:timer
timeout /t 60 /nobreak
echo Checking for updates...
Set /A TIME=TIME+60
if %TIME%==3600 goto:check
goto :updates

:restart
taskkill -im "BeamMP-Server.exe"
echo Server shutdown
goto :start
2 Likes