Skip to content

Commit

Permalink
Start arr manager service
Browse files Browse the repository at this point in the history
  • Loading branch information
JackDallas committed Aug 11, 2022
1 parent 80506f4 commit 4cfdee6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/premiumizearrd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions internal/service/arrs_manager_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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{
Expand All @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion internal/service/transfer_manager_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 4cfdee6

Please sign in to comment.