Arma 3 Funny Server Restart Script

Here's my scripts, they work for me :)
Ofcourse you need to edit all file links.
I run all cmd's as administrator.

I start my server using restartserver.cmd and stop it using stopserver.cmd.
The scripts and BEC scheduler do the rest.
My scheduler.xml is set to reboot the server after 8 hours of uptime.

Scheduler.xml for BEC:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<!--
This file is only provided as an example file and is not practical to use in real life.
Make sure you take a copy of this file rename it and keep the orginale intact for orginale refrance.
And Start using your new file Now!!

Web Doc : http://www.ibattle.org/install-and-configure/setting-up-the-scheduler/

BE Commands supported by the scheduler system are:

say -1 some text
loadbans
loadscripts
loadevents
writebans
maxping 250
#shutdown
#restart
#reassign
#lock
#unlock
#mission filename (without the .pbo extension)
systime
uptime
fortune

*****************************************************************************************************
Description:
*****************************************************************************************************

Schedules are created by adding a job with id.
The first schedule should always start with id="0"

<Scheduler>
<job id="0">
<day></day>
<start></start>
<runtime></runtime>
<loop></loop>
<cmd></cmd>
</job>
<job id="1">
<day></day>
<start></start>
<runtime></runtime>
<loop></loop>
<cmd></cmd>
</job>
</Scheduler>

The job tag has 5 sub tags.

starting with:

<day>.../day>

The day of the week the schedule should run on.
Days are seperated by ','
<day>n</day> or <day>n,n+</day>

Monday starts with 1!

All days
<day>1,2,3,4,5,6,7</day>

Monday and Friday only.
<day>1,5</day>

Next:
<start>......</start>
This tag may have one of two input format.

Format 1:
Contains 3 segments where each segment is a size of 2 in range of 00 - 99
Hour Min  Sec
[nn] [nn] [nn]
nnnnnn
Max value is 999999 and min value is 000000

<start>000090</start>
This will make the schedule execute 90 seconds after bec has started up and logged in.
Note that:

<start>000130</start>
Will also make the schedule execute 90 seconds after bec has started up.
as 90 sec is the same as 1 min and 30 sec

 Format 2:
Contains 2 segments where each segment is a size of 2 in range of 00 - (23&59) and each segment is seperated by ':'

Hour   Min    Sec
[nn] : [nn] : [nn]

<start>23:05:30</start>
This will make the schedule execute precice at 23:05:30

To execute a schedule at midnight use:
<start>00:00:00</start>

To execute a schedule at noon use:
<start>12:00:00</start>

Next:
<runtime>....../runtime>
This tag uses the same format as the <start> tag format 1 (hhmmss), it also only work when the loop is set to -1 or higher than 0. ie 10
<runtime>hhmmss</runtime>

Next:
<loop>N</loop>

If -1 is used it means it will loop forever.
If 0 is used the job will only be run once.
If a number higher than 0 is used it will loop the set numbers.
Each loop interval is set in the runtime tag.

Example.
<runtime>001000</runtime>
<loop>5</loop>

this means that the job will loop 6 times with a 10 minute delay between each job after the jobstart
once "start" + number of loops

Next:
<cmd>Command</cmd>
Set the command that is to be executed.

you can use external commands. example
<cmd>c:\path\myfile.bat</cmd>

or just use a internal command.
<cmd>uptime</cmd>

SEE THE SCHEDULER_FAQ.txt for more info

-->

<Scheduler>

<!-- this job will start after 10 minutes and run forever with a 1 hour and 30 minutes interval between the jobs -->
<job id='0'>
<day>1,2,3,4,5,6,7</day>
<start>003000</start>
<runtime>003000</runtime>
<loop>-1</loop>
<cmd>say -1 This server restarts every 8 hours of uptime - type !upt in Global Chat to see running time</cmd>
</job>

<!-- this job will start after 30 seconds and will only run once. note that the runtime tag is ignored when loop is 0 -->
<job id='1'>
<day>1,2,3,4,5,6,7</day>
<start>003200</start>
<runtime>003000</runtime>
<loop>-1</loop>
<cmd>say -1 Teamspeak IP  --  ts.nlelite.nl</cmd>
</job>

<!-- This job wil start after 3 hours of runtime -->
<job id='2'>
<day>1,2,3,4,5,6,7</day>
<start>070000</start>
<runtime>070000</runtime>
<loop>0</loop>
<cmd>say -1 RESTART IN ONE HOUR</cmd>
</job>
<job id='3'>
<day>1,2,3,4,5,6,7</day>
<start>073000</start>
<runtime>073000</runtime>
<loop>0</loop>
<cmd>say -1 RESTART IN 30 MINUTES -- RESTART IN 30 MINUTES</cmd>
</job>
<job id='4'>
<day>1,2,3,4,5,6,7</day>
<start>075000</start>
<runtime>075000</runtime>
<loop>0</loop>
<cmd>say -1 RESTART IN 10 MINUTES - START PREPARING TO LOG OUT</cmd>
</job>
<job id='5'>
<day>1,2,3,4,5,6,7</day>
<start>075500</start>
<runtime>075500</runtime>
<loop>0</loop>
<cmd>say -1 RESTART IN 5 MINUTES - START PREPARING TO LOG OUT</cmd>
</job>
<job id='6'>
<day>1,2,3,4,5,6,7</day>
<start>075800</start>
<runtime>075800</runtime>
<loop>0</loop>
<cmd>say -1 RESTART IN 2 MINUTES - SAVE GEAR AND LOG OUT</cmd>
</job>
<job id='7'>
<day>1,2,3,4,5,6,7</day>
<start>075900</start>
<runtime>080000</runtime>
<loop>0</loop>
<cmd>say -1 RESTART IN 1 MINUTE - SAVE GEAR AND LOG OUT</cmd>
</job>
<job id='8'>
<day>1,2,3,4,5,6,7</day>
<start>080000</start>
<runtime>080000</runtime>
<loop>0</loop>
<cmd>D:\games\ArmA3\A3Startup\restartserver.cmd</cmd>
</job>

</Scheduler>


start and restart scripts.

restartserver.cmd:

@echo off
::SHUTDOWN SERVERMONITOR IF IT IS ALREADY RUNNING - WE RESTART IT AT THE END OF THIS
taskkill /f /im cmd.exe /fi "WINDOWTITLE eq Administrator:  servermonitor.cmd"
taskkill /f /im conhost.exe /fi "WINDOWTITLE eq Administrator:  servermonitor.cmd"
echo Make sure all is clear
timeout 1

::MAKE SURE ALL TASKS ARE REALLY STOPPED
taskkill /f /fi "status eq not responding" /im arma3server.exe
taskkill /f /im arma3server.exe
timeout 1

:: KILL BATTLEYE IF IT ISN'T ALREADY
taskkill /im Bec.exe
timeout 1

:: KILL ARMASERVERMONITOR
taskkill /im ArmaServerMonitor.exe
timeout 1

::RESTARTING THE ARMA 3 SERVER BE SURE TO EDIT THIS TO YOUR SERVER .EXE LOCATION -NOTE ALSO THIS IS WHERE YOU DEFINE WHERE YOU CONFIG.CFG IS
cd /d D:\games\ArmA3\A3Server\
start "arma3" /realtime /affinity FF "arma3server.exe" -port=2302 "-config=D:\games\ArmA3\A3Startup\A3Wasteland\config.cfg" "-cfg=D:\games\ArmA3\A3Startup\A3Wasteland\basic.cfg" "-profiles=D:\games\ArmA3\A3Startup\A3Wasteland" -name=A3Wasteland -pid=a3_prod.pid -ranking=a3_prod_ranking.log "-mod=@ASM" -malloc=tbbmalloc -enableHT -cpuCount=2 -exThreads=3
timeout 6
echo ARMA 3 Server has started

::RESTARTING ARMASERVERMONITOR
cd /d D:\games\ArmA3\A3Server\
start "" "ArmaServerMonitor.exe"
timeout 6
echo ArmaServerMonitor is started

::RESTARTING BATTLEYE
set becpath="D:\games\ArmA3\Bec\"
cd /d %becpath%
start "" "Bec.exe" -f Config.cfg
timeout 3
echo Battleye has started..
echo.
echo.
echo Starting ARMA 3 Server...

:: THIS RUNS THE SERVER MONITOR FOR YOU SO YOU DON'T FORGET
set ServerMonitorPath="D:\games\ArmA3\A3Startup\"
cd /d %ServerMonitorPath%
start "" "servermonitor.cmd"
echo Server Monitor has started. Have Fun
timeout 5
exit


servermonitor.cmd:

@echo off
::IMPORTANT TO NAME IT SO WE CAN KILL IT
title servermonitor.cmd
:start
C:\Windows\System32\tasklist /FI "IMAGENAME eq arma3server.exe" 2>NUL | C:\Windows\System32\find /I /N "arma3server.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
echo Server is not running, will be started now
start "" /min /wait "D:\games\ArmA3\A3Startup\restartserver.cmd"
timeout 30
echo Server started succesfully
goto started
:loop
cls
echo Server is already running, running monitoring loop
:started
::THE 80 REFERS TO SECONDS AND HOW OFTEN IT WILL CHECK,YOU CAN SET IT TO WHATEVER YOU WANT. I JUST DONT WANT MY SERVER DOWN FOR MUCH LONGER THAN THAT!
::New error fault kill, will check for err fault and clear it and hopefully restart, a little more promise but no guarantee :)
taskkill /f /im WerFault.exe /fi "WINDOWTITLE eq Arma 3"
C:\Windows\System32\timeout /t 80
C:\Windows\System32\tasklist /FI "IMAGENAME eq arma3server.exe" 2>NUL | C:\Windows\System32\find /I /N "arma3server.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
goto start

stopserver.cmd:

@echo off
::KILL ARMA3 SERVER
taskkill /f /fi "status eq not responding" /im arma3server.exe
taskkill /f /im arma3server.exe
timeout 1
::DOUBLE CHECK KILL
taskkill /f /fi "status eq not responding" /im arma3server.exe
taskkill /f /im arma3server.exe
timeout 1
:: KILL BATTLEYE
taskkill /im Bec.exe
timeout 1
::KILL SERVER MONITOR
taskkill /f /im cmd.exe /fi "WINDOWTITLE eq Administrator:  servermonitor.cmd" /T
taskkill /f /im conhost.exe /fi "WINDOWTITLE eq Administrator:  servermonitor.cmd" /T
timeout 1
::KILL ARMASERVERMONITOR
taskkill /im ArmaServerMonitor.exe
timeout 1
::KILL ALL COMMAND.EXE THAT ARE OPEN
taskkill /f /fi "status eq not responding" /im cmd.exe
taskkill /f /im cmd.exe
taskkill /f /fi "status eq not responding" /im conhost.exe
taskkill /f /im conhost.exe
timeout 1
::DOUBLE TAP
taskkill /f /fi "status eq not responding" /im cmd.exe
taskkill /f /im cmd.exe
taskkill /f /fi "status eq not responding" /im conhost.exe
taskkill /f /im conhost.exe
timeout 1

freemansoftelp.blogspot.com

Source: http://forums.a3wasteland.com/index.php?topic=613.0

Related Posts

0 Response to "Arma 3 Funny Server Restart Script"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel