Created
December 1, 2021 14:55
-
-
Save JuanRamino/56832a9207adf0ed24a3a5bfac8f3fbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start-Job -ScriptBlock { | |
$ipaddress = '127.0.0.1' | |
$port = 3000 | |
$try = 0 | |
$sleepTime = 10 | |
while(1) { | |
Start-Sleep -s $sleepTime | |
try { | |
$connection = New-Object System.Net.Sockets.TcpClient($ipaddress, $port) | |
Write-Output "$(Get-Date -Format u) - app is running" | |
$sleepTime = 5 | |
} | |
catch { | |
if ($try -eq 3) { | |
Write-Output "$(Get-Date -Format u) - app down quit" | |
exit | |
} else { | |
$try = $try + 1 | |
Write-Output "$(Get-Date -Format u) - app down try $try" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment