From 257cabb737e625f5376a857261b292e169f18f60 Mon Sep 17 00:00:00 2001 From: reloxx13 Date: Thu, 22 Oct 2020 12:38:50 +0200 Subject: [PATCH] add the updated restarter script --- ...Multiple-Instances-of-Radarr-on-Windows.md | 134 +++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/Installing-Multiple-Instances-of-Radarr-on-Windows.md b/Installing-Multiple-Instances-of-Radarr-on-Windows.md index fb6b82c..515705d 100644 --- a/Installing-Multiple-Instances-of-Radarr-on-Windows.md +++ b/Installing-Multiple-Instances-of-Radarr-on-Windows.md @@ -42,4 +42,136 @@ Since the first Radarr instance will occupy port 7878, the second instance must ## Notes ## * Though this tutorial was tested using Command Prompt, it should work with Windows Terminal as well. But, if you're feeling cautious, just go with Command Prompt. * A previous version of this installation guide encouraged users to copy Radarr's config.xml file to Radarr-4K's data directory. However, you'll run into trouble with this method, especially if you have authentication enabled. I'd recommend starting with a clean config.xml file, created when you start the service for the first time (Step 7). -* If one Radarr instance is updated, both instances will shutdown and only the updated one will start again. To fix this, you will have to manually start the other instance, or you may want to look into using [this script by reloxx](https://www.reddit.com/r/radarr/comments/hou8ro/winps_multiple_instances_restarter/) to address the problem until an official solution is found. \ No newline at end of file +* If one Radarr instance is updated, both instances will shutdown and only the updated one will start again. To fix this, you will have to manually start the other instance, or you may want to look into using the below powershell script to address the problem until an official solution is found. + + +## Port Checker and Restarter PowerShell Script + +When you use two Radarr instances and one of it is updating, it will kill both instances ( by killing all running radarr.console.exe ). +Only the one which is updating will come back online. + +To keep both online i made a powershell script which i run as a scheduled task. + +It checks the ports and if one is not online, it will (re-)start the scheduled task to launch radarr. + + +Create a new File and name it `RadarrInstancesChecker.ps1` with the below code. + +Create a scheduled task which triggers on launch and set it to repeat every 5 or 10mins. +- Trigger: + - On launch + - Repeat every 5 or 10 mins +- Action: + - Launch Application/Programm + - Enter `powershell` as programm + - Add your script as argument: `-File D:\RadarrInstancesChecker.ps1` + + + +Adjust ur pathes, ip, ports and scheduled task names. + +RadarrInstancesChecker.ps1 +``` +################################################################################################ +### RadarrInstancesChecker.ps1 ### +################################################################################################ +### Keeps multiple Radarr Instances up by checking the port ### +### Please use Radarr Discord or Reddit for support! ### +### https://github.com/Radarr/Radarr/wiki/Installing-Multiple-Instances-of-Radarr-on-Windows ### +################################################################################################ +### Version: 1.1 ### +### Updated: 2020-10-22 ### +### Author: reloxx13 ### +################################################################################################ + + + +### SET YOUR CONFIGURATION HERE ### +# Set your host ip and port correctly and use your service or scheduledtask names! + +# (string) The type how Radarr is starting +# "Service" (default) Service process is used +# "ScheduledTask" Task Scheduler is used +$startType = "Service" + +# (bool) Writes the log to C:\Users\YOURUSERNAME\log.txt when enabled +# $false (default) +# $true +$logToFile = $false + + +$instances = @( + [pscustomobject]@{ # Instance 1 + Name='Radarr-V3'; # (string) Service or Task name (default: Radarr-V3) + IP='192.168.178.12'; # (string) Server IP where Radarr runs (default: 192.168.178.12) + Port='7873'; # (string) Server Port where Radarr runs (default: 7873) + } + [pscustomobject]@{ # Instance 2 + Name='Radarr-4K'; # (string) Service or Task name (default: Radarr-V3) + IP='192.168.178.12'; # (string) Server IP where Radarr runs (default: 192.168.178.12) + Port='7874'; # (string) Server Port where Radarr runs (default: 7874) + } + # If needed you can add more instances here... + # [pscustomobject]@{ # Instance 3 + # Name='Radarr-3D'; # (string) Service or Task name (default: Radarr-V3) + # IP='192.168.178.12'; # (string) Server IP where Radarr runs (default: 192.168.178.12) + # Port='7875'; # (string) Server Port where Radarr runs (default: 7875) + # } +) + + +### DONT CHANGE ANYTHING BELOW THIS LINE ### + + +### +# This function will write to a log file or in console output +### +function Write-Log { + #Will write to C:\Users\YOURUSERNAME\log.txt + + Param( + $Message, + $Path = "$env:USERPROFILE\log.txt" + ) + + function TS {Get-Date -Format 'hh:mm:ss'} + + #Console output + Write-Output "[$(TS)]$Message" + + #File Output + if($logToFile){ + "[$(TS)]$Message" | Tee-Object -FilePath $Path -Append | Write-Verbose + } +} + + +Write-Log "START =====================" + + +$instances | ForEach-Object { + Write-Log "Check $($_.Name) $($_.IP):$($_.Port)" + + $PortOpen = ( Test-NetConnection $_.IP -Port $_.Port -WarningAction SilentlyContinue ).TcpTestSucceeded + + if (!$PortOpen) { + Write-Log "Port $($_.Port) is closed, restart $($startType) $($_.Name)!" + + if($startType -eq "Service"){ + Get-Service -Name $_.Name | Stop-Service + Get-Service -Name $_.Name | Start-Service + } + elseif($startType -eq "ScheduledTask"){ + Get-ScheduledTask -TaskName $_.Name | Stop-ScheduledTask + Get-ScheduledTask -TaskName $_.Name | Start-ScheduledTask + } + else{ + Write-Log "[ERROR] STARTTYPE UNKNOWN! USE Service or ScheduledTask !" + } + }else{ + Write-Log "Port $($_.Port) is open!" + } +} + +Write-Log "END =====================" +``` \ No newline at end of file