Jump to content

Automatic Restarter


ricky

Recommended Posts

Does anyone know if a way to make the server automatically restart with warning messages?

 

To do this on a Windows operating system, i had to figure this out myself, so i'm not very good at it yet.

I know people will have a better way to do this. I would appreciate it and i'm sure others would too if you could share.

If you don't like this script and don't have a better way to do it, then don't bother giving your opinion. ;)

 

If you can't make sense of what the code is doing then i don't recommend you doing this.

First you need to download, autoit

Google it. I'm not posting a link for it. :)

 

When you've installed it. Make a text file called: StartServerScript.au3

And a text file called: StartServer.bat

Add them to your "steamapps\common\ProjectZomboid"

 

In the StartServerScript.au3 put:

 

While 1
Local $iPID = Run("E:\SteamLibrary\steamapps\common\ProjectZomboid\StartServer.bat", "", @SW_SHOWDEFAULT)
Sleep(1000 * 60 * 60 * 6) ;wait 6 hours
WinActivate("PZ Server")
Sleep(200)
WinActivate("PZ Server")
Send("servermsg Server restart in 10 minutes.{ENTER}")
Sleep(1000 * 60 * 10) ;wait 10 minutes
WinActivate("PZ Server")
Send("servermsg Server restart in 5 minutes.{ENTER}")
Sleep(1000 * 60 * 5) ;wait 5 minutes
WinActivate("PZ Server")
Send("servermsg Server restart in 1 minute.{ENTER}")
Sleep(1000 * 60) ;wait 1 minute
WinActivate("PZ Server")
Send("quit{ENTER}")
Sleep(1000 * 10) ;wait for shutdown
WEnd
 
and in StartServer.bat put this:
 
@Echo off
taskkill /im java*
echo -------------------------------------
echo Trimming all map files under 10kb...
pushd "R:\Zomboid\Multiplayer\servertest"
for %%j in (*) do if %%~zj lss 10000 del %%j
echo Map files trimmed.
echo -------------------------------------
Echo Clear descriptors.bin map_meta.bin map_t.bin and Blam Folder...
del /Q descriptors.bin map_meta.bin map_t.bin blam
Echo Map Reset.
echo -------------------------------------
popd
Echo Starting Server...
start "PZ Server" /high ".\jre64\bin\java.exe" -Xms1G -Xmx8G -Duser.home=R:\ -Djava.library.path=./ -cp lwjgl.jar;lwjgl_util.jar;sqlitejdbc-v056.jar;trove-3.0.3.jar;uncommons-maths-1.2.3.jar;./ zombie.network.GameServer
exit
 
If you want your server to do a backup when restarting then add this above the Map Trim and below taskkill:
echo -------------------------------------
echo Copying Files to Backup Folder...
xcopy /Q /Y "C:\Zomboid\Multiplayer\servertest" "D:\Zomboid Backups"
echo -------------------------------------
 
Then go through both files and make sure your paths are correct.
Then just run StartServerScript.au3 and it'll run these scripts automatically.
 
If you like it feel free to say thanks. I'm probably going to figure out how to do it by time and improve it some.
It's a learning progress for me. So if you're not happy with it, then you could learn something too. :)
Link to comment
Share on other sites

I had something similar like this setup. I think that it's easier done on linux from what I've heard.  This is the closest I could get just using batch, note this does not announce anything in game. This is setup for two servers though.

 

 

@echo off
:loop
echo starting Zeek's Haven....
timeout /t 15 >null
start "PVP Server" ".\jre64\bin\java.exe" -Xms2g -Xmx12g -Duser.home=P:\ -Djava.library.path=./ -cp lwjgl.jar;lwjgl_util.jar;sqlitejdbc-v056.jar;trove-3.0.3.jar;uncommons-maths-1.2.3.jar;./ zombie.network.GameServer -debuglog=Combat
echo 1 minutes before RP server loads...
timeout /t 30 >null
echo 30 seconds before RP server loads...
timeout /t 30 >null
echo starting RP server...
start "RP Server" ".\jre64\bin\java.exe" -Xms2g -Xmx12g -Duser.home=Z:\ -Djava.library.path=./ -cp lwjgl.jar;lwjgl_util.jar;sqlitejdbc-v056.jar;trove-3.0.3.jar;uncommons-maths-1.2.3.jar;./ zombie.network.GameServer -debuglog=Combat
echo 2 hours till restarting of servers...
timeout /t 3600 >null
echo 1 hour till restarting of servers...
timeout /t 1800 >null
echo 30 minutes till restarting of servers...
timeout /t 900 >null
echo 15 minutes till restarting of servers...
timeout /t 780 >null
echo 2 minutes till restarting of servers...
timeout /t 60 >null
echo 1 minutes till restarting of servers...
timeout /t 60 >null
taskkill /f /im "java.exe" >nul
taskkill /f /im "java.exe" >nul
goto loop
Link to comment
Share on other sites

This would shut the server down incorrectly though right? and could possibly corrupt maps? if it's not using the "quit" command in the server window?

I'm sure there has to be a way to do servermsg. I can think of a way to do it with macro programs but i tend to not trust them. If i find out i'll be-sure to share it.

 

p.s. i recommend putting /high in the startup bat Zeek.

 

"start "RP Server" ".\jre64\bin\java.exe" /high"

Link to comment
Share on other sites

This was a test I did for one night. I no longer use this of course.  As you said, it would incorrectly close the server down.  I wouldn't recommend using /high as it could have unwanted effects on the performance of other services vital to running the system. Networking could take a hit, input polling rate could be affected and many other services that may need equal priority could start missing appropriate timings.

 

It has always been recommended by Microsoft and other tech specialist to lower the priority of programs and services that you find unnecessary rather than to up priorities. This of course was originally intended for single threaded computers. On a multi-threaded system the affects are much less drastic, but can cause problems over time if used on a process that is using all threads.

Link to comment
Share on other sites

Anything that is immediate, like all online games should be set to high for the best response time. You don't set things to realtime as this is what will effect drivers and the operating system.

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...