Moore

Auto-Restart (Release)

23 posts in this topic

Hello everybody I hope this is in the correct section and apologize in advance if it is not. So recently it seems that the server auto-restart standard (BEC) has been having issues and doesn't seem to be receiving further support. Although there are work arounds for this I felt that maybe everybody was ready for something that was a little easier and much more user friendly. I've been using this batch startup system for years now and never once have had an issue with it, so I figured I should share with the community! I had made this awhile ago when I was first starting out and have since added on to make it easier and more simplistic, because why should restarts be so darned difficult? Anyway, without further adue, lets begin!

Step 1: For starters lets get this out of the way. You will need a dedicated box. Simple as that. It will need to be on Windows OS. That's all I ever used and all I plan on ever using. Whether or not it works on others I would not know.

Step 2: Create a batch file in your main server directory (Where your "arma3server.exe" is located) and name it something along the lines of auto restart. So for example you will end up with "autorestart.bat". Now to create a batch file simply create a new text document, open it up, "Save as..", Select "All Files", then type in "autorestart.bat". Now you can exit the document and delete the "New Text Document".

Step 3: Right click on your newly created "autorestart.bat" and select "Edit". You can either use the default text editor or notepad++, either one will work. 

Step 4: Paste the following information in your empty batch file you've just created:

::Made by Moore for use with BLAH BLAH Server
@echo off
color 0a
title Moore's Auto-Restarter Example Altis Exile
C:\Windows\System32\mode con cols=50 lines=3 >nul
set /a var=0
:start
echo Running Server
start "" /wait /realtime /affinity F "arma3server.exe" -port=2302 "-config=Config\cfg\Config.cfg" "-profiles=Config\log" "-cfg=Config\cfg\basic.cfg" -name=Exile "-servermod=@ExileServer;" "-mod=@Exile;"  -autoinit -enableHT -malloc=system
set /a var+=1
cls
echo Server has shutdown %var% times, restarting
goto start

Step 5: After pasting the information in you will need to change some things...

  • Title (4th Line) - Simply change that to what you would like to name the cmd proccess that will be running. (Usually the server name)
  • Directory/Mods, etc (9-10th Line) - Basically leave it as is, however edit as needed to point towards your proper config files, mods, and such.

Step 6: Your Done! Simple as that. If you have set it up properly, you simply double click this batch file to start the server and it will do the rest for you. Basically it starts the server, and will continuously monitor it for when it shuts down. And when it shut's down it will restart it and keep a track of how many times it has restarted since the first start-up.

Step 7 (Recommended): This file DOES NOT shutdown the server for you. The reason I have it like that is because Exile Devs have been nice enough to provide a nifty RCon system built in. However, there is a catch. This system needs to be modified and here's how we're going to do that. (If you use other means to shutdown the server then you can stop reading here, otherwise continue on!)

Step 8: We need to custom compile the servers RCon thread check, so we can execute a shutdown sequence. Open your servers mission file and create a .sqf file. Name this .sqf file "ExileServer_system_rcon_thread_check". So you will end up with "ExileServer_system_rcon_thread_check.sqf". Place alongside your init.sqf.

Step 9: Paste this code inside that file...and save it!:

/**
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_restartTime","_restartMessages","_useAutoKick","_kickTime","_lockTime","_uptime","_timeTilRestart","_time","_i"];
_restartTime = _this select 0;
_restartMessages = _this select 1;
_useAutoKick = _this select 2;
_kickTime = _this select 3;
_lockTime = _this select 4;
_uptime = call ExileServer_util_time_uptime;
_timeTilRestart = _restartTime - _uptime;
if (typeName _restartMessages isEqualTo "ARRAY") then
{
	if !(_restartMessages isEqualTo []) then
	{
		{
			_time = _x;
			if (_timeTilRestart < _time) then
			{
				if !(ExileSessions isEqualTo []) then
				{
					["notificationRequest",["RestartWarning",[format["Server restart in %1 min!",_time]]]] call ExileServer_system_network_send_broadcast;
				};
				ExileServerRestartMessages deleteAt _forEachIndex;
				format ["Restart Warrnings for %1min sent",_time] call ExileServer_util_log;
			};
		} 
		forEach _restartMessages;
	};
};
if (_timeTilRestart < _lockTime) then
{
	if !(ExileServerIsLocked) then
	{
		"#lock" call ExileServer_system_rcon_event_sendCommand;
		"Server locked for restart" call ExileServer_util_log;
		["notificationRequest",["LockKickWarning",["You will be kicked from the server due to restart."]]] call ExileServer_system_network_send_broadcast;
		ExileServerIsLocked = true;
	};
	if (_timeTilRestart < _kickTime) then
	{
		if !(ExileServerRestartMode) then
		{
			call ExileServer_system_rcon_event_kickAllrestart;
			"Everyone kicked for restart" call ExileServer_util_log;
			call ExileServer_system_rcon_event_clearBuffers;
			"Buffers cleared!" call ExileServer_util_log;
			for "_i" from 0 to 9 do
			{
				"SERVER READY FOR RESTART!!" call ExileServer_util_log;
			};
			ExileServerRestartMode = true;
			uiSleep 10;
			"#shutdown" call ExileServer_system_rcon_event_sendCommand;
		};
	};
};
true

Step 10: (Almost Done!) We need to tell the server that we want to handle this script in the mission file instead of the exile_server. To do that locate your config.cpp inside your mission file. Open it up and located "CfgExileCustomCode". Now under that class we are simply going to add this: ExileServer_system_rcon_thread_check = "ExileServer_system_rcon_thread_check.sqf";

So you should end up with :

class CfgExileCustomCode 
{
	ExileServer_system_rcon_thread_check = "ExileServer_system_rcon_thread_check.sqf";
};

Step 11: Done! Save it, repack the mission.pbo, and be sure to configure your restarts how you like. 

I know I said that was going to be simple (and personally it still is), but for anybody with at least intermediate skills in server development, you should be able to understand it and make great use of it.

I hope you all enjoy and remember to give credit where credit is do as always!

 

Credits: Auto-Restart Batch - Created by Moore (But you all know that by now :D)

             RCon Thread Check - Do not know his name (Sorry!), but I had saw it posted by someone other than me. And after looking over my old batch file and this thread check I figured this was more efficient.

Edited by Moore
  • Like 4

Share this post


Link to post
Share on other sites

This is good but really BEC has a new owner and also give support on there team speak you should check it out ibattle.org also this is the easiest method for people that don' t want to play around creating 5 bat files to get BEC working with auto restarts. 

Nice post :)

  • Like 2

Share this post


Link to post
Share on other sites
Advertisement

Yes exactly. My goal was to streamline the process. I very much enjoyed BECs schedule system, however I felt like it was constantly needing attention which is great for some, but others just need to be able to rely on a 24/7 completely reliable restart method. I didn't mean to knock BEC at all it is definitely by far one of the best, but some people, like you said, just don't have the knowledge to run multiple batch files with BEC. So I figured something for the more low maintenance servers would be great to share!

Share this post


Link to post
Share on other sites

@bliskin its not your fault. Exile changed one line of code that needs to be adjusted in this script

If you are experiencing faulty restart messages do the following:

Replace "if !(ExileSessions isEqualTo []) then" in "ExileServer_system_rcon_thread_check.sqf" file you created

With "if (count ExileSessionIDs > 0) then"

if !(_restartMessages isEqualTo []) then
	{
		{
			_time = _x;
			if (_timeTilRestart < _time) then
			{
				if !(ExileSessions isEqualTo []) then
				{

PROFIT !

:monkey:

 

Edited by S.
  • Like 3

Share this post


Link to post
Share on other sites

As @S said. However I don't utilize their messages anyway. I use infistar as well as a modified Status Bar to notify players of an immanent restart

  • Like 1

Share this post


Link to post
Share on other sites

As @S said. However I don't utilize their messages anyway. I use infistar as well as a modified Status Bar to notify players of an immanent restart

I will once i get back from this amazing weekend make a post with complete bec set up. All you will have to do is change you info. Bec is the route to take no offense Exile but you restars are not reliable enough.

Share this post


Link to post
Share on other sites

As @S said. However I don't utilize their messages anyway. I use infistar as well as a modified Status Bar to notify players of an immanent restart

Hey Moore, I see you use the infiSTAR restart messages. have you ever  had an issue where the server refuses to unlock when it comes back from a restart? Is there away to bypass the need infiSTAR has for the:

 // Autolocks server until its ready to accept players
        useAutoLock = 1;

?

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.