From 4cfdee6bc7c6493bcb98718ed44c7f849af35cd4 Mon Sep 17 00:00:00 2001 From: Jack Dallas <3620144+JackDallas@users.noreply.github.com> Date: Thu, 11 Aug 2022 12:52:06 +0100 Subject: [PATCH] Start arr manager service --- cmd/premiumizearrd/app.go | 2 +- internal/service/arrs_manager_service.go | 4 ++++ internal/service/transfer_manager_service.go | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/premiumizearrd/app.go b/cmd/premiumizearrd/app.go index b0089f4..a98dc34 100644 --- a/cmd/premiumizearrd/app.go +++ b/cmd/premiumizearrd/app.go @@ -24,7 +24,6 @@ type App struct { func (app *App) Lock() {} func (app *App) UnLock() {} -//Start func (app *App) Start(logLevel string, configFile string, loggingDirectory string) error { //Setup static login lvl, err := log.ParseLevel(logLevel) @@ -98,6 +97,7 @@ func (app *App) Start(logLevel string, configFile string, loggingDirectory strin // Must come after transfer, arrManager and directory app.webServer.Init(&app.transferManager, &app.directoryWatcher, &app.arrsManager, &app.config) + app.arrsManager.Start() app.webServer.Start() app.directoryWatcher.Start() //Block until the program is terminated diff --git a/internal/service/arrs_manager_service.go b/internal/service/arrs_manager_service.go index c47e88e..0fb543d 100644 --- a/internal/service/arrs_manager_service.go +++ b/internal/service/arrs_manager_service.go @@ -27,6 +27,7 @@ func (am *ArrsManagerService) Init(_config *config.Config) { func (am *ArrsManagerService) Start() { am.arrs = []arr.IArr{} + log.Debugf("Starting ArrsManagerService") for _, arr_config := range am.config.Arrs { switch arr_config.Type { case config.Sonarr: @@ -38,6 +39,7 @@ func (am *ArrsManagerService) Start() { LastUpdate: time.Now(), } am.arrs = append(am.arrs, &wrapper) + log.Tracef("Added Sonarr arr: %s", arr_config.Name) case config.Radarr: c := starr.New(arr_config.APIKey, arr_config.URL, 0) wrapper := arr.RadarrArr{ @@ -47,10 +49,12 @@ func (am *ArrsManagerService) Start() { LastUpdate: time.Now(), } am.arrs = append(am.arrs, &wrapper) + log.Tracef("Added Radarr arr: %s", arr_config.Name) default: log.Error("Unknown arr type: %s, not adding Arr %s", arr_config.Type, arr_config.Name) } } + log.Debugf("Created %d Arrs", len(am.arrs)) } func (am *ArrsManagerService) Stop() { diff --git a/internal/service/transfer_manager_service.go b/internal/service/transfer_manager_service.go index dcabd68..2336dfd 100644 --- a/internal/service/transfer_manager_service.go +++ b/internal/service/transfer_manager_service.go @@ -69,7 +69,7 @@ func (t *TransferManagerService) CleanUpUnzipDir() { log.Errorf("Error cleaning unzip directory: %s", err.Error()) return } - + } func (manager *TransferManagerService) ConfigUpdatedCallback(currentConfig config.Config, newConfig config.Config) { @@ -110,6 +110,7 @@ func (manager *TransferManagerService) TaskUpdateTransfersList() { } manager.updateTransfers(transfers) + log.Tracef("Checking %d transfers against %d Arr clients", len(transfers), len(manager.arrsManager.GetArrs())) for _, transfer := range transfers { found := false for _, arr := range manager.arrsManager.GetArrs() {