Jump to content
RAGE Multiplayer Community

[SCRIPT][WINDOWS] Relaunch server automatically on crash


Wdoyle
 Share

Recommended Posts

Hi there,

If you are doing a windows server deployment for your server and want a method for keeping your server running at all times incase of crashes etc. This also allows you to terminate it externally via another application and it will reboot (ideally if updates are managed by source control)

while ($true)
{
    if ((Get-Process -Name ragemp-server -ErrorAction SilentlyContinue) -eq $null)
    {
        Write-Host -ForegroundColor Red "Server Is Not Running"
        Set-Location -Path C:\RageMP\Server-Files
	$date = Get-Date -Format G
        write-host -ForegroundColor Green "Guardian Started Headless RageMP Server 1.1 $($date)"
        ./ragemp-server.exe
    }
    else
    {
        write-host -ForegroundColor Green "Server Is Running"
    }

    Start-Sleep -Seconds 10
}

To run and test this - I would recommend starting with: Windows PowerShell ISE. This is a Microsoft tool that allows you to test your scripts before saving them.

Save this as a Powershell script ie servermaintain.ps1

If the script is running successfully you will see the logs from the Rage Server directly within the Powershell window. You will just need to create a scheduled task (in Windows) to launch your powershell on boot or login to make sure it is always running (if your server host is restarted)

  • Like 2
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
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...