-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswu_checkserver.ps1
24 lines (22 loc) · 1023 Bytes
/
swu_checkserver.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Parameters ###################
$script_folder = "C:\Rust" #Your script_folder
$check_interval = 300 #Interval to check server in seconds
################################
$host.ui.RawUI.WindowTitle = "SwuCheckServer"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProcessNameToCheck = @("RustDedicated", "SwuStartServer")
while ($TRUE){
Write-Host "Check RustDedicated is running..."
$RustDedicatedIsRunning = Get-Process -Name $ProcessNameToCheck[0] -ErrorAction SilentlyContinue
$StartServerIsRunning = Get-Process powershell | Where-Object {$_.MainWindowTitle -match $ProcessNameToCheck[1]}
if (!$RustDedicatedIsRunning -and !$StartServerIsRunning) {
Write-Host "RustDedicated KO..."
Write-Host "Start server"
$argList = "-file `"$($script_folder)\swu_startserver.ps1`""
Start-Process powershell -ArgumentList $argList
} else {
Write-Host "RustDedicated OK"
}
Write-Host "Sleep $($check_interval) seconds..."
Start-Sleep -s $check_interval
}