Jump to content
Sign in to follow this  

7 Days to Die Server Utility


Dateranoth
  • I modified my Cube World Server Utility to work with 7 Days to Die. I also added a customizable ini file.

    NOTE! If you do not use the PuttyTel client to restart all restarts are hard restarts. The server process is closed, and it is closed when you exit the script. I have tested this, and it doesn't seem to be affecting save files, but you have been warned.

    Features:

    • Optional Daily Restarts
    • Keep Server Alive. Restart on Crash
    • Log Excessive Memory Use
    • Option to Restart on Excessive Memory Use
    • Option to Remotely Restart Server
    • Logs restart request, current memory being used, and if the utility requested or a certain IP
    • Safely shutdown the server through telnet via puttytel.exe and save server day

    The remote restart utility is a separate program. It allows you to connect and remotely restart a server.

    You can download the 7dServerUtility and 7dServerRemoteRestart compiled exe's HERE. (VirusScan)

    You can download the 7dServerUtility and 7dServerRemoteRestart AutoIT Source HERE.

    A special thanks to Nightmare from the 7 days to die forum for the telnet info!

Installation Instructions:

Place 7dServerUtility.exe in the same directory as 7DaysToDie.exe and run once. It will create a default INI file that you will need to modify for your server. Once you have modified the ini, restart the script and enjoy.

If you want to use Putty to safely shutdown the server, then visit http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and download puttytel.exe .

Place puttytel.exe in the same directory as 7dServerUtility.exe

Remote Restart Instructions:

Run 7dServerRemoteRestart.exe from anywhere. It will create a default INI file that you must modify. Modify the INI file and fill in the server IP and Restart Port. Optionally you can fill in the password field and it will save it so you don't have to type it each time.

7dServerUtility.au3

#include #include <Date.au3>#include <Process.au3>;User VariablesIf FileExists("7dServerUtility.ini") Then   Local $GamePort = IniRead("7dServerUtility.ini", "GameServerPort", "GamePort", "25000")   Local $ConfigFile = IniRead("7dServerUtility.ini", "GameConfigFile", "ConfigFile", "serverconfig.xml")   Local $UseRemoteRestart = IniRead("7dServerUtility.ini", "Use_Remote_Restart?yes/no", "UseRemoteRestart", "no")   Local $g_IP = IniRead("7dServerUtility.ini", "IP_To_Listen_On", "ListenIP", "127.0.0.1")   Local $g_Port = IniRead("7dServerUtility.ini", "Port_To_Listen_On", "ListenPort", "57539")   Local $RestartCode = IniRead("7dServerUtility.ini", "Remote_Restart_Password", "RestartCode", "FVtb2DXgp8SYwj7J")   Local $RestartDaily= IniRead("7dServerUtility.ini", "Restart_Daily?yes/no", "RestartDaily", "no")   Local $HotHour = IniRead("7dServerUtility.ini", "Restart_Time_Hour?00-23", "HotHour", "00")   Local $HotMin = IniRead("7dServerUtility.ini", "Restart_Time_Minute?00-59", "HotMin", "01")   Local $ExMem = IniRead("7dServerUtility.ini", "Excessive_Memory_Amount", "ExMem", "2000000000")   Local $ExMemRestart = IniRead("7dServerUtility.ini", "Restart_On_Excessive_Mem_Use?yes/no", "ExMemRestart", "no")Else   IniWrite("7dServerUtility.ini", "GameServerPort", "GamePort", "25000")   IniWrite("7dServerUtility.ini", "GameConfigFile", "ConfigFile", "serverconfig.xml")   IniWrite("7dServerUtility.ini", "Use_Remote_Restart?yes/no", "UseRemoteRestart", "no")   IniWrite("7dServerUtility.ini", "IP_To_Listen_On", "ListenIP", "127.0.0.1")   IniWrite("7dServerUtility.ini", "Port_To_Listen_On", "ListenPort", "57539")   IniWrite("7dServerUtility.ini", "Remote_Restart_Password", "RestartCode", "FVtb2DXgp8SYwj7J")   IniWrite("7dServerUtility.ini", "Restart_Daily?yes/no", "RestartDaily", "no")   IniWrite("7dServerUtility.ini", "Restart_Time_Hour?00-23", "HotHour", "00")   IniWrite("7dServerUtility.ini", "Restart_Time_Minute?00-59", "HotMin", "01")   IniWrite("7dServerUtility.ini", "Excessive_Memory_Amount", "ExMem", "2000000000")   IniWrite("7dServerUtility.ini", "Restart_On_Excessive_Mem_Use?yes/no", "ExMemRestart", "no")   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")   ExitEndIfOnAutoItExitRegister("CloseServer")Func CloseServer()   If FileExists(@ScriptDir & "\puttytel.exe") Then	  $PuttyPort = $GamePort+3	  Run(@ScriptDir & "\puttytel.exe -P "& $PuttyPort & " "& $g_IP)	  WinWait($g_IP &" - PuTTYtel","")	  Local $CrashCheck = WinWait("PuTTYtel Fatal Error","",5)	  If $CrashCheck = 0 Then		 ControlSend($g_IP &" - PuTTYtel", "", "", "{enter}")		 ControlSend($g_IP &" - PuTTYtel", "", "", "shutdown{enter}")		 WinWait("PuTTYtel Fatal Error","",10)		 Local $PID = ProcessExists("puttytel.exe")		 If $PID Then			ProcessClose($PID)		 EndIf	  Else 		 Local $PID = ProcessExists("puttytel.exe")		 Local $PID2 = ProcessExists("7DaysToDie.exe")			If $PID Then			   ProcessClose($PID)			EndIf			If $PID2 Then			   ProcessClose($PID2)			EndIf	  EndIf   Else      Local $PID = ProcessExists("7DaysToDie.exe")	  If $PID Then		 ProcessClose($PID)	  EndIf   EndIfEndFuncFunc _TCP_Server_ClientIP($hSocket)   Local $pSocketAddress, $aReturn   $pSocketAddress = DllStructCreate("short;ushort;uint;char[8]")   $aReturn = DllCall("ws2_32.dll", "int", "getpeername", "int", $hSocket, "ptr", DllStructGetPtr($pSocketAddress), "int*", DllStructGetSize($pSocketAddress))   If @error Or $aReturn[0] <> 0 Then Return $hSocket	  $aReturn = DllCall("ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($pSocketAddress, 3))   If @error Then Return $hSocket	  $pSocketAddress = 0   Return $aReturn[0] EndFunc ;==>_TCP_Server_ClientIPIf $UseRemoteRestart = "yes" Then; Start The TCP ServicesTCPStartup()Local $MainSocket = TCPListen($g_IP, $g_Port, 100)If $MainSocket = -1 Then ExitEndIfwhile True	if WinExists("Oops!") Then		ControlSend("Oops!", "", "", "{enter}")		Sleep (10000)	EndIfIf $UseRemoteRestart = "yes" ThenLocal $ConnectedSocket = TCPAccept($MainSocket)If $ConnectedSocket >= 0 Then;TrayTip("Connected","Someone connected to server.",3)$Count = 0While $Count < 30$RECV = TCPRecv($ConnectedSocket,512)   If $RECV = $RestartCode Then   Local $PID = ProcessExists("7DaysToDie.exe") ; Will return the PID or 0 if the process isn't found.   	  If $PID Then		 $IP = _TCP_Server_ClientIP($ConnectedSocket)		 Local $MEM = ProcessGetStats($PID, 0)		 FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _		 " --Peak Memory:"& $MEM[1] &" Restart Requested by Remote Host: "& $IP)		 ;ProcessClose($PID)		 CloseServer()		 Sleep (10000)		 ExitLoop	  EndIf   EndIf$Count += 1Sleep (1000)WEndIf $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)EndIfEndIfLocal $PID = ProcessExists("7DaysToDie.exe")If $PID = 0 Then   Run(@ScriptDir & "\7DaysToDie.exe -quit -batchmode -nographics -configfile="& $ConfigFile &" -dedicated")   Sleep (70000)Else    Local $MEM = ProcessGetStats($PID, 0)   If $MEM[0] > $ExMem And $ExMemRestart = "no" Then	  FileWriteLine(@ScriptDir & "\7dServerUtility_ExcessiveMemoryLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _        " --Peak Memory:"& $MEM[1])	  Sleep (10000)   ElseIf $MEM[0] > $ExMem And $ExMemRestart = "yes" Then	  FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _	  " --Peak Memory:"& $MEM[1] &" Excessive Memory Use - Restart Requested by 7dServerUtility Script")	  ;ProcessClose($PID)	  CloseServer()	  Sleep (10000)   EndIfEndIf       If @HOUR = $HotHour And @MIN = $HotMin And $RestartDaily = "yes" Then    Local $PID = ProcessExists("7DaysToDie.exe")	  If $PID Then		 Local $MEM = ProcessGetStats($PID, 0)		 FileWriteLine(@ScriptDir & "\7dServerUtility_RestartLog.txt", @MON &"-"& @MDAY &"-"& @YEAR &" "& @HOUR &":"& @MIN &" --Work Memory:"& $MEM[0] & _		 " --Peak Memory:"& $MEM[1] &" Daily Restart Requested by 7dServerUtility Script")		 ;ProcessClose($PID)		 CloseServer()	  EndIf   Sleep (10000)    EndIfSleep (500)WEnd  

7dServerRemoteRestart.au3

; Start The TCP Services    ;==============================================    TCPStartup()   ; Set Some reusable info   ;--------------------------   Local $ConnectedSocket, $szDataIf FileExists("7dServerRemoteRestart.ini") Then   Local $szIPADDRESS = IniRead("7dServerRemoteRestart.ini", "GameServerIP", "szIPADDRESS", "127.0.0.1")   Local $nPORT = IniRead("7dServerRemoteRestart.ini", "RestartServerPort", "nPORT", "57539")   Local $RPassword = IniRead("7dServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")Else   IniWrite("7dServerRemoteRestart.ini", "GameServerIP", "szIPADDRESS", "127.0.0.1")   IniWrite("7dServerRemoteRestart.ini", "RestartServerPort", "nPORT", "57539")   IniWrite("7dServerRemoteRestart.ini", "DefaultRestartPassword", "RPassword", "")   MsgBox(4096, "Default INI File Made", "Please Modify Default Values and Restart Script")   ExitEndIf    ; Initialize a variable to represent a connection    ;==============================================    $ConnectedSocket = -1    ;Attempt to connect to SERVER at its IP and PORT 57539    ;=======================================================    $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)    ; If there is an error... show it    If @error Then	    MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)	    ; If there is no error loop an inputbox for data	    ;   to send to the SERVER.    Else	    ;Loop forever asking for data to send to the SERVER	    While 1		    ; InputBox for data to transmit		    $szData = InputBox("Reset The 7 Days to Die Server", @LF & @LF & "Enter the code to Reset The 7 Days to Die Server:",$RPassword)		    ; If they cancel the InputBox or leave it blank we exit our forever loop		    If @error Or $szData = "" Then ExitLoop		    ; We should have data in $szData... lets attempt to send it through our connected socket.		    ; convert AutoIt native UTF-16 to UTF-8		    TCPSend($ConnectedSocket, StringToBinary($szData, 4))            ExitLoop		    ; If the send failed with @error then the socket has disconnected		    ;----------------------------------------------------------------		    If @error Then ExitLoop	    WEnd     EndIfIf $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)TCPShutdown()

Sign in to follow this  


User Feedback

Recommended Comments

v1.2 is out. Nightmare from the 7 Days to Die forum was nice enough to share the telnet info for the server.

 

Now with the use of puttytel.exe the server can be safely shutdown instead of just having the process killed. This saves the time and helps make sure blocks are saved.  Simply download the new script from here, then download puttytel.exe from Putty's Site and place both in the directory containing 7daystodie.exe

Share this comment


Link to comment
Share on other sites

Update: Fixed Server forcefully shutting down when exiting script. It will now use PuTTyTel.exe to gracefully shutdown if available.

Also wanted to note that Putty is optional, if you don't place puttytel.exe in the directory with the script, it will force the process to close instead.

Share this comment


Link to comment
Share on other sites

Hi everyone, this looks really helpful.  I have a question, I am running on a dedicated remote server, running multiple servers on the hardware and wanted to ask if this can manage multiple servers? 

 

Has anyone used this for more than one server running on a machine before?  

Thanks,

 

Hunter

Share this comment


Link to comment
Share on other sites

In its current state it will work as long as you follow these guidelines:

You have to use PuttyTel to shut down.

You will need to run a separate instance for each server and each server will need to be its own directory.

You will need to change the listen ports for the remote shutdown to be different from each other.

Finally, it may not be necessary, but I recommend you stagger the daily restart times by at least 5 minutes.

Share this comment


Link to comment
Share on other sites

Any new updates in the works for this utility? I absolutely love your Conan Server Utility and I would love to have the same for the 7 Days To Die.  I wish for the same features: automatically check for and install updates (stable and experimental) and notify Discord or in-game users of server restarts.

Thanks!  I would also be willing to donate if it would motivate :)

-Phoenix125.com

Quote

 

 

Share this comment


Link to comment
Share on other sites

I haven't written any programs since my Commodore 64 days, but I am going to work on updating your 7dServerUtility to include the latest features of your ConanServerUtility.  I am also going to add a parameter to enable it to work with the latest experimental 7DTD version. THANK YOU very much for posting your AutoIT Source codes for the Server Utility programs!

Share this comment


Link to comment
Share on other sites

7dtdServerUtility - A Utility To Keep Your 7 days To Die Dedicated Server updated (and schedule server restarts, download and install new server files, and more!)
- Latest version: 7dtdServerUtility_v2.2.1 
(2019-03-13)  (v2.2.0 Added taskbar options: send telnet commands with 1 click, autoupdate utility, No longer restarts server when steamcmd update check fails, lots of other minor improvements.) 

New Beta Version! 7dtdServerUpdateUtility v2.3.0(beta1) (2019-03-22)  *New BETA Features*
- Window showing online users and current date/time, online user log
- New Tray menu options: Update server, Send Messages/commands, Restart server

- By Phoenix125 | http://www.Phoenix125.com | http://discord.gg/EU7pzPs | kim@kim125.com
- Based on Dateranoth's ConanExilesServerUtility-3.3.0 and ServerUtility | https://gamercide.org/

FEATURES
- New! "Future Proof" After updates, adds 19 existing parameters to the new serverconfig.xml file, if needed, to account for config changes.
- OK to use with most other server managers: Use this tool to install and maintain the server and use your other tools to manage game play features.
- Automatically download and install a new 7 Days To Die Dedicated Server: No need to do it manually.
- Automatically keeps server updated.
- Announce server updates and restarts in game chat and on Discord, Twitch, and MCRCON.
- Works with both STABLE and EXPERIMENTAL versions.
- Optionally automatically add version (ex: 'Alpha 17 (b240)' or 'b240') to server name with each update, so that users can quickly identify that you are running the latest version.
- Optionally automatically rename GameName to current version (ex: Alpha 17 b240) with each update, therefore saving old world while creating new world (aka: SERVER WIPE).
- KeepServerAlive: Detects server crashes and will restart the server.
- User-defined scheduled reboots.
- Remote restart.
- Run multiple instances of 7dtdServerUtil to manage multiple servers.
- Clean shutdown of your server.
- Retain detailed logs of 7DTD dedicated server and 7dtdServerUtility.
- Optionally restart server on excessive memory use.

DOWNLOAD LINKS
Latest Version: http://www.phoenix125.com/share/7dtdServerUtility.zip
Latest BETA Version: http://www.phoenix125.com/share/7dtdServerUpdateUtilityBeta.zip
Previous Versions: http://www.phoenix125.com/share/7dtdhistory/
Readme.txt: http://www.phoenix125.com/share/readme.txt
BETA readme: http://www.phoenix125.com/share/BETA_VERSION_Use_Only_On_Test_Servers!!!.txt

Website: http://www.Phoenix125.com
Discord: http://discord.gg/EU7pzPs

CREDITS
- Based on Dateranoth's ConanExilesServerUtility-3.3.0 and ServerUtility (THANK YOU!)
https://gamercide.org/forum/topic/9296-7-days-to-die-server-utility/
https://gamercide.org/forum/topic/10558-conan-exiles-server-utility/

Share this comment


Link to comment
Share on other sites

Sorry I haven't been around to see this! Been a bit busy of late, but I'm glad you were able to update this to continue working with 7days to Die!  I'm not always on top of the posts, but if you need me, shoot me a Direct Message.

Share this comment


Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Members

    No members to show

  • Member Statistics

    519
    Total Members
    1,025
    Most Online
    Geant
    Newest Member
    Geant
    Joined
  • Twitch Streams

×
×
  • Create New...