From e977e66cbc813f8db07de38ff1904934b51ce95a Mon Sep 17 00:00:00 2001 From: fpiesche Date: Sun, 25 Sep 2022 02:11:22 +0100 Subject: [PATCH 1/3] Make postgres, redis and jackett hosts configurable. --- .env | 3 +++ packages/api/src/config.ts | 15 +++++++++------ .../api/src/modules/jackett/jackett.service.ts | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 5bb8e9f4..8bbde149 100644 --- a/.env +++ b/.env @@ -10,12 +10,15 @@ UMASK_SET=0002 PUID=510 PGID=20 +POSTGRES_HOST=postgres POSTGRES_DB=bobarr POSTGRES_USER=bobarr POSTGRES_PASSWORD=bobarr +REDIS_HOST=redis REDIS_PASSWORD=bobarr +JACKETT_HOST=jackett JACKETT_AUTOMATIC_SEARCH_TIMEOUT=120000 JACKETT_MANUAL_SEARCH_TIMEOUT=15000 diff --git a/packages/api/src/config.ts b/packages/api/src/config.ts index fd3e224a..3436998f 100644 --- a/packages/api/src/config.ts +++ b/packages/api/src/config.ts @@ -1,6 +1,6 @@ export const DB_CONFIG = { type: 'postgres' as const, - host: 'postgres', + host: process.env.POSTGRES_HOST || 'postgres' , port: 5432, username: process.env.POSTGRES_USER, password: process.env.POSTGRES_PASSWORD, @@ -11,15 +11,18 @@ export const DB_CONFIG = { export const DEBUG_REDIS = process.env.DEBUG_REDIS === 'true' || false; export const REDIS_CONFIG = { - host: 'redis', + host: process.env.REDIS_HOST, port: 6379, password: process.env.REDIS_PASSWORD, }; -export const JACKETT_RESPONSE_TIMEOUT = { - automatic: Number(process.env.JACKETT_AUTOMATIC_SEARCH_TIMEOUT), - manual: Number(process.env.JACKETT_MANUAL_SEARCH_TIMEOUT), -}; +export const JACKETT_CONFIG = { + timeoutAutomatic: Number(process.env.JACKETT_AUTOMATIC_SEARCH_TIMEOUT), + timeoutManual: Number(process.env.JACKETT_MANUAL_SEARCH_TIMEOUT), + host: process.env.JACKETT_HOST || 'jackett', + port: process.env.JACKETT_PORT || '9117', + +} export const LIBRARY_CONFIG = { moviesFolderName: process.env.LIBRARY_MOVIES_FOLDER_NAME, diff --git a/packages/api/src/modules/jackett/jackett.service.ts b/packages/api/src/modules/jackett/jackett.service.ts index 0252dc1b..827fa7d7 100644 --- a/packages/api/src/modules/jackett/jackett.service.ts +++ b/packages/api/src/modules/jackett/jackett.service.ts @@ -22,7 +22,7 @@ import { Tag } from 'src/entities/tag.entity'; import { JackettResult, JackettIndexer } from './jackett.dto'; import { Entertainment } from '../tmdb/tmdb.dto'; import { PromiseRaceAll } from 'src/utils/promise-resolve'; -import { JACKETT_RESPONSE_TIMEOUT } from 'src/config'; +import { JACKETT_CONFIG } from 'src/config'; @Injectable() export class JackettService { @@ -42,7 +42,7 @@ export class JackettService { ); const client = axios.create({ - baseURL: 'http://jackett:9117/api/v2.0/indexers/all', + baseURL: `http://{JACKETT_CONFIG.host}:{JACKETT_CONFIG.port}/api/v2.0/indexers/all`, params: { apikey: jackettApiKey }, }); @@ -176,8 +176,8 @@ export class JackettService { const resolvedIndexers = await PromiseRaceAll( allIndexers, opts.withoutFilter - ? JACKETT_RESPONSE_TIMEOUT.manual - : JACKETT_RESPONSE_TIMEOUT.automatic + ? JACKETT_CONFIG.timeoutManual + : JACKETT_CONFIG.timeoutAutomatic ); const flattenIndexers = resolvedIndexers .filter((item) => Boolean(item)) From 73fc55b37007f5db2c5a4d4838e86e8a3f5db8b3 Mon Sep 17 00:00:00 2001 From: fpiesche Date: Sun, 25 Sep 2022 02:20:02 +0100 Subject: [PATCH 2/3] Make Transmission host and port configurable --- packages/api/src/config.ts | 5 +++++ .../api/src/modules/transmission/transmission.service.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/api/src/config.ts b/packages/api/src/config.ts index 3436998f..65c6fd19 100644 --- a/packages/api/src/config.ts +++ b/packages/api/src/config.ts @@ -24,6 +24,11 @@ export const JACKETT_CONFIG = { } +export const TRANSMISSION_CONFIG = { + host: process.env.TRANSMISSION_HOST || 'transmission', + port: process.env.TRANSMISSION_PORT || '9091' +} + export const LIBRARY_CONFIG = { moviesFolderName: process.env.LIBRARY_MOVIES_FOLDER_NAME, tvShowsFolderName: process.env.LIBRARY_TV_SHOWS_FOLDER_NAME, diff --git a/packages/api/src/modules/transmission/transmission.service.ts b/packages/api/src/modules/transmission/transmission.service.ts index 47a1fb0e..87538b27 100644 --- a/packages/api/src/modules/transmission/transmission.service.ts +++ b/packages/api/src/modules/transmission/transmission.service.ts @@ -10,9 +10,11 @@ import { Torrent } from 'src/entities/torrent.entity'; import { TorrentDAO } from 'src/entities/dao/torrent.dao'; import { LazyTransaction } from 'src/utils/lazy-transaction'; +import { TRANSMISSION_CONFIG } from 'src/config'; + @Injectable() export class TransmissionService { - private client = new Transmission({ host: 'transmission' }); + private client = new Transmission({ host: TRANSMISSION_CONFIG.host, port: TRANSMISSION_CONFIG.port }); public constructor( @Inject(WINSTON_MODULE_PROVIDER) private logger: Logger, From 30866d7d9d8d61874cc8b58590886b6a53b1067c Mon Sep 17 00:00:00 2001 From: fpiesche Date: Sun, 25 Sep 2022 02:20:46 +0100 Subject: [PATCH 3/3] Add default for TRANSMISSION_HOST to env --- .env | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env b/.env index 8bbde149..6770a168 100644 --- a/.env +++ b/.env @@ -18,6 +18,8 @@ POSTGRES_PASSWORD=bobarr REDIS_HOST=redis REDIS_PASSWORD=bobarr +TRANSMISSION_HOST=transmission + JACKETT_HOST=jackett JACKETT_AUTOMATIC_SEARCH_TIMEOUT=120000 JACKETT_MANUAL_SEARCH_TIMEOUT=15000