Results 1 to 1 of 1

Thread: Starting/Running A Dedicated Server using MS Powershell. A Watchdog.

  1. #1
    Supporting Member
    Join Date
    Feb 2015
    Posts
    325
    Post Thanks / Like
    Total Downloaded
    277.05 MB

    Starting/Running A Dedicated Server using MS Powershell. A Watchdog.

    This is a way to keeping a dedicated server process running on a server. By restarting it automatically whenever it stops.
    I created this to use it myself, and this post is simply here to share this, so anyone here can use it, should one want to. There's no copyright or whatever disclaimers from my side. Use at your own risk...
    There probably are even better ways to do this ... but this is just my way.

    Now for sure, nothing bad about Colanders Server commander / ATAG Clod watchdog, as it does a mighty fine job keeping a dedicated server running.
    That watchdog also keeps an eye on Steam client being running. But, I found out recently that when using the dedicated server option for Cliffs, Steam does not have to be running.(Not sure when that happened)

    I am all for keeping a lean setup on a server, so to have the least amount of stuff running. So, now steam does not have to be running, that would mean having to stop using Atag server commander!
    (As it always starts Steam automatically, should it not be running.)

    So, I did come up with a different way to start the dedicated server, and to keep it running...

    Did this using a Powershell script, which checks whether Launcher64 is running as a process, and if it is not, it will start it.
    (It's not entirely compatible with the server commander, as it does not start/load a mission, so it cannot run several different missions in a row, as the server commander can do.
    I use the file Settings.cmd to get that done.)

    One batch file (StartClodWatched.cmd) starts the Powershell script each and every 60 seconds, that script will start Cliffs of Dover's Launcher64 - if needed.

    This is the content of the batch file that starts the Powershell script, which checks the Launcher64 process existence. The script is being started every 60 seconds.
    (You can easily change the frequence, by editing the batch file, and replace the 60 in Timeout /t 60 with a higher or lower number of seconds.

    Code:
    @Echo Off
    
    Rem Will start Launcher once it is not running, does it every 60 seconds
    Rem One Time only manual action:
    Rem Run powershell as admin and execute this command: set-executionpolicy -ExecutionPolicy Bypass
    
    :Again
    cls
    @echo Check and start if not running.
    start /min powershell -windowstyle hidden -command .\CheckLauncher64.ps1
    
    Rem Wait 60 seconds
    Timeout /t 60
    Goto Again
    Here's the code of the Powershell script file CheckLauncher64.ps1
    Code:
    $ProcessActive = Get-Process Launcher64 -ErrorAction SilentlyContinue | ? {$_.SI -eq (Get-Process -PID $PID).SessionId}
    if($ProcessActive -eq $null)
    {
     Write-host "IsNotRunning, Do Start Process"
     "MissionFile was started." | Out-File -FilePath .\RunningMission.txt
    C:
    cd "C:\Steam\steamapps\common\IL-2 Sturmovik Cliffs of Dover Blitz"
    Start-Process -FilePath "Launcher64.exe" -ArgumentList "-server"
    }
    else
    {
     Write-host "IsRunning, Do Nothing"
    }
    This file may need some editing, as it points to the location where the Launcher64 is.

    Installation/Setup:
    Copy the two files that are in the attached zip file to a folder on your computer/server, does not really matter where, as long as they are in the same folder.
    Edit the file CheckLauncher64.ps1 so the CD command matches the location of the Launcher64.exe on your computer/server.

    To get it running, there is one thing that needs to be done once, as by default, windows will not let you run any powershell scripts from a batch file.
    Start Powershell with admin rights (right click Windows Start button, click Windows Powershell (Admin)
    Copy paste this command into the shell, and press Enter key.
    Code:
    set-executionpolicy -ExecutionPolicy Bypass
    Then doubleclick 'StartClodWatched.cmd' and you should be good to go... One Window will show up, looking like this:
    image_2020-10-03_132652.png

    This setup is currently running on both DangerDogz servers, and it does its job.

    Note:
    Starting a Powershell script like this may be judged as a threat by some antivirus/threat detection software.
    I know for a fact BitDefender really does not like this setup, and simply blocks it from running.
    Have submitted a report for that at BitDefender, but I have not heard anything back from them just yet.


    Attachment 50098
    Attached Files Attached Files
    Last edited by DD_FT; May-21-2021 at 19:05.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •