Jump to content

Tool to restart the server and BEC after #shutdown.


ifordmc

Recommended Posts

Get rid of all those closed tools and the #shutdown command. Just use a simple batch file and call it in your sheduler.xml:
 

@echo off
echo.
echo KILL arma3server.exe
set serverkill="C:\arma3\a3master"
cd /d %serverkill%
taskkill /im arma3server.exe /F
echo.

timeout 5

echo.
echo Rotate Logfiles
set logs="C:\arma3\a3master"
cd /d %logs%
start "" "rotate-logs.bat"
echo.

timeout 5

echo.
echo Start Arma 3
set logs="C:\arma3\a3master"
cd /d %logs%
start "" "start-a3-epoch.bat" (This is only a batch file with startup parameters for a3server)
echo.

timeout 10

echo.
echo START BEC
set bec="C:\arma3\a3master\bec"
cd /d %bec%
start "" "bec.exe" -f a3config.cfg
echo.
exit
Link to comment
Share on other sites

It can be done with a .bat file easily.  costs nothing. requires no download. This is mine.

@echo off
color 0a
title Server Starter
:top
echo Launching And Watching Server
start /wait "arma3" /min "H:\A3poch\arma3server.exe" -mod=@Epoch;@EpochHive; -config=H:\A3poch\SC\config.cfg -ip=127.0.0.1 -port=6662 -profiles=SC -cfg=H:\A3poch\SC\basic.cfg -name=SC
ping 127.0.0.1 -n 5 >NUL
echo Server has exited ... Restarting!
ping 127.0.0.1 -n 1 >NUL
cls
goto top 

And since i dont have BEC on A3 epoch this is from DayZ epoch. Shouldn't be hard to figure out how to make it work for you

@echo off
color 0a
title Server Starter
:top
echo Launching And Watching BEC
ping 127.0.0.1 -n 30 >NUL
start /wait "" /min "H:\overpochinsServer\ServerTools\bec.exe" -f config.cfg
ping 127.0.0.1 -n 5 >NUL
echo Server has exited ... Restarting!
cls
goto top 

These will start and wait for them to shut down, then do it again. Until the prompts the bats bring up are closed, the server will restart evey time it shuts down then 30sec later BEC will do the same. Also place shortcuts to these in startup if you want the server to boot back on computer restart for those that arent keeping them online all of the time for test servers as well.

 

EDIT: I didnt read the post. Just the title, But anyway batch would be the way to go if you ask me. Uses virtually no power of any sort from the box its running on. Any app however, will.

Link to comment
Share on other sites

It can be done with a .bat file easily.  costs nothing. requires no download. This is mine.

@echo off
color 0a
title Server Starter
:top
echo Launching And Watching Server
start /wait "arma3" /min "H:\A3poch\arma3server.exe" -mod=@Epoch;@EpochHive; -config=H:\A3poch\SC\config.cfg -ip=127.0.0.1 -port=6662 -profiles=SC -cfg=H:\A3poch\SC\basic.cfg -name=SC
ping 127.0.0.1 -n 5 >NUL
echo Server has exited ... Restarting!
ping 127.0.0.1 -n 1 >NUL
cls
goto top 

And since i dont have BEC on A3 epoch this is from DayZ epoch. Shouldn't be hard to figure out how to make it work for you

@echo off
color 0a
title Server Starter
:top
echo Launching And Watching BEC
ping 127.0.0.1 -n 30 >NUL
start /wait "" /min "H:\overpochinsServer\ServerTools\bec.exe" -f config.cfg
ping 127.0.0.1 -n 5 >NUL
echo Server has exited ... Restarting!
cls
goto top 

These will start and wait for them to shut down, then do it again. Until the prompts the bats bring up are closed, the server will restart evey time it shuts down then 30sec later BEC will do the same. Also place shortcuts to these in startup if you want the server to boot back on computer restart for those that arent keeping them online all of the time for test servers as well.

 

EDIT: I didnt read the post. Just the title, But anyway batch would be the way to go if you ask me. Uses virtually no power of any sort from the box its running on. Any app however, will.

Spot on, thats working great for me so far. Great.

 

And yeah, this seems far more simple then a program.

Link to comment
Share on other sites

It can be done with a .bat file easily.  costs nothing. requires no download. This is mine.

-snip-

These will start and wait for them to shut down, then do it again. Until the prompts the bats bring up are closed, the server will restart evey time it shuts down then 30sec later BEC will do the same. Also place shortcuts to these in startup if you want the server to boot back on computer restart for those that arent keeping them online all of the time for test servers as well.

 

EDIT: I didnt read the post. Just the title, But anyway batch would be the way to go if you ask me. Uses virtually no power of any sort from the box its running on. Any app however, will.

I cant seem to get the BEC starter to run. It launches the bat but BEC itself does not start.

Link to comment
Share on other sites

I had problems with Arma 2 not shutting down properly with the taskkill command via a batch file.  Even with the /f switch enabled.   Sometimes the app would not exit and then when the server restarted it would be on some random port since the old server still had hold of the intended port.  So to fix that I use the #shutdown command in my BEC scheduler and then I have a program that runs the restart batch.  System Scheduler is a free program that works great.  It can start exe files, bat files, you name it.  Haven't had a single hiccup since I started using this method.  

Link to comment
Share on other sites

I had problems with Arma 2 not shutting down properly with the taskkill command via a batch file.  Even with the /f switch enabled.   Sometimes the app would not exit and then when the server restarted it would be on some random port since the old server still had hold of the intended port.  So to fix that I use the #shutdown command in my BEC scheduler and then I have a program that runs the restart batch.  System Scheduler is a free program that works great.  It can start exe files, bat files, you name it.  Haven't had a single hiccup since I started using this method.  

I've been using the same bat for over a year. And when it once did start a second instance of the arma server, I just increased the timeout. Haven't had a problem since.

@echo off

:initialize
cls
echo Killing current running server ...
taskkill /IM arma3server.exe /F
taskkill /IM Bec.exe /F
echo Done!
timeout 10
echo.

echo. Rotate Logfiles
cd C:\A3Epoch
start "" "log-rotator.cmd"
echo Done!
timeout 5

goto start

:start
cd C:\A3Epoch
echo Starting server again ...
start "arma3" your startup params
echo.

:start_bec
timeout 20
echo.
cd C:\Bec
echo Starting BEC again ...
@start Bec.exe -f Config.cfg
exit
Link to comment
Share on other sites

This is an open source tool that I have been using for a while to run both my Arma 2 Epoch Server and BEC as a Windows service with good success.  It's free and pretty simple to configure.  It has the advantage of being able to start your Arma server and BEC automatically in the event of a power failure, or BSOD.

 

I'm running both my A2 Epoch and A3 Epoch servers in a Windows 2008 (x64) environment.

 

https://github.com/kohsuke/winsw

 

Get the complied binaries for Windows here:  (I am using version 1.6).

 

http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/

 

To setup the service, copy the winsw-1.16-bin.exe to the directory alongside the executable you want to run as a server and rename it something logical.  I call my Arma3 version: Arma3serversvc.exe

 

Create a blank text file with the same name as the executable with a .xml extension.  Arma3serversvc.xml

 

Edit the xml as follows:

<service>
  <id>arma3server</id>
  <name>Arma3server</name>
  <description>Arma3 Server Service.</description>
  <executable>C:\arma3server\arma3server.exe</executable>
	<arguments> -nosplash -nosound -mod=@Epoch;@EpochHive; -config=C:\arma3server\SC\config.cfg -ip=xx.xx.xx.xx -port=2302 -profiles=SC -cfg=C:\arma3server\SC\basic.cfg -name=SC</arguments>  
  <logpath>C:\Arma3server\servicelogs</logpath>
  <logmode>append</logmode>
</service>

Modify the executable paths and arguments line to fit your Arma3 server installation.  You can name the service what ever you like.  The ID, name and description are up to you.  Note I wouldn't use spaces in the id or service name however.

 

Create a servicelogs folder in the location of the Arma3 server files.  This will allow you to monitor startups, shutdowns, errors, etc.  This is important.  If you don't create a folder, the service install will fail.

 

Open a command prompt (as administrator) and navigate to the location of the service executable file.

 

At the command prompt enter:  arma3serversvc.exe install

 

If everything goes as planned, this will install the service.  Check the services applet in Control Panel to see if the service is listed.

 

If the install errors out check for typos or issues with the xml file and try again to install.  You can uninstall the service with the uninstall switch if needed.

 

For BEC, you have to add an additional option for working directory.  Here is my xml file for BEC.

<service>
  <id>beca3svc</id>
  <name>beca3svc</name>
  <description>BEC Arma3 Service.</description>
  <executable>C:\arma3server\bec\bec.exe</executable>
  <workingdirectory>C:\arma3server\bec</workingdirectory>
	<arguments> -f config.cfg --dsc</arguments>  
  <logpath>C:\Arma3server\bec\servicelogs</logpath>
  <logmode>append</logmode>
</service>

Once the services are installed, start them and make sure they run without any errors.  Connect to your server and RCON to see if BEC is running properly.

 

Now it's a simple as making a small batch file and scheduling that via the Windows Task Scheduler to execute when you want the server to restart.

@echo off
net stop arma3server

timeout 5

net start arma3server

timeout 5

net stop beca3svc

timeout 5

net start beca3svc

Even though I have the BEC scheduler issue a #shutdown command (which shuts down BEC as well once the server connection drops) I issue a net stop for both the services anyway to ensure they are stopped.  This won't hurt anything and provides some redundancy in case BEC errors and your scheduler stops running.  Your server will restart anyway.

 

You will want to adjust your batch file to rotate logs, make backups (or whatever) as you see fit.

 

Both my Arma2 and Arma3 servers run on a 3 hour restart cycle.  As services I can restart both servers and both BEC instances with one batch file.  There are ways to stop and start services via a webpage with some .net sorcery, but you will have to google for that.

 

Hope this helps someone as an alternative to Firedeamon.

 

Link to comment
Share on other sites

 

 

here a mine server monitors included so if somehting crashes will auto start back up

 

stopserver.bat

 

@echo off
TIMEOUT 25
tASKkill /im arma3server.exe



Epoch.bat
@echo off
: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 monitored is not running, will be started now 
start "" /wait "D:\Games\dedicated\arma3server.exe" -mod=@Epoch;@EpochHive; -config=D:\Games\dedicated\SC\config.cfg -port=2302 -profiles=SC -cfg=d:\gAMES\dedicated\SC\basic.cfg -name=SC
echo Server started succesfully
goto started
:loop
cls
echo Server is already running, running monitoring loop
:started
C:\Windows\System32\timeout /t 10
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
 
and BEC.bat
 
@echo off
:start
C:\Windows\System32\tasklist /FI "IMAGENAME eq Bec.exe" 2>NUL | C:\Windows\System32\find /I /N "Bec.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
echo Server monitored is not running, will be started now 
start "" /wait "D:\Games\BEC\Bec.exe" -f config.cfg
echo Server started succesfully
goto started
:loop
cls
echo Server is already running, running monitoring loop
:started
C:\Windows\System32\timeout /t 10
C:\Windows\System32\tasklist /FI "IMAGENAME eq Bec.exe" 2>NUL | C:\Windows\System32\find /I /N "Bec.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop
goto start

 

 

just get your scheduler.xml to run the stop server .bat and the other batch files do the rest 

Link to comment
Share on other sites

It is meant for missions that actually end and is not designed with the DLL/hive extension in mind. They could possibly get it to work but would need a lot of code working. It works OK for stock a3 missions but not with epoch AFAIK, at least not atm and doubt it ever will tbh.

Regards

Link to comment
Share on other sites

It is meant for missions that actually end and is not designed with the DLL/hive extension in mind. They could possibly get it to work but would need a lot of code working. It works OK for stock a3 missions but not with epoch AFAIK, at least not atm and doubt it ever will tbh.

Regards

 

Just tested using #restart on my server, it does reset the map, everything is refreshed, including loot, doors etc.. if you are logged in and playing during the #restart you will lose items, I don't know what the trigger is or if it is an interval to save your data to the redis is so I cannot give a exact answer.  All I know if I logged in my server, grabbed some loot, pushed the #restart command via Rcon and when I logged in I no longer had my items and I was in my previous spawn point.

 

Kind Regards,

-b3ck

Link to comment
Share on other sites

  • 3 weeks later...

 

I've been using the same bat for over a year. And when it once did start a second instance of the arma server, I just increased the timeout. Haven't had a problem since.

@echo off

:initialize
cls
echo Killing current running server ...
taskkill /IM arma3server.exe /F
taskkill /IM Bec.exe /F
echo Done!
timeout 10
echo.

echo. Rotate Logfiles
cd C:\A3Epoch
start "" "log-rotator.cmd"
echo Done!
timeout 5

goto start

:start
cd C:\A3Epoch
echo Starting server again ...
start "arma3" your startup params
echo.

:start_bec
timeout 20
echo.
cd C:\Bec
echo Starting BEC again ...
@start Bec.exe -f Config.cfg
exit

 

What are you using in your scheduler to start this .bat file?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...