1 Commits
Author SHA1 Message Date
Worph f70bb52aab config fix feeder
Publish image / publish (push) Failing after 14s
2026-07-01 18:54:12 +02:00
2 changed files with 25 additions and 56 deletions
+15 -12
View File
@@ -7,12 +7,16 @@
//! torrent-core TMDB catalog-discovery stack. Split out of `meta-feeder-torrent` //! torrent-core TMDB catalog-discovery stack. Split out of `meta-feeder-torrent`
//! so its dashboard config panel resolves to the tribler schema. //! so its dashboard config panel resolves to the tribler schema.
//! //!
//! Env (shared): `META_FEEDER_HTTP_LISTEN` (default `0.0.0.0:8080`), //! ALL tribler config — sidecar URL, api key, tmdb token/language, meta-core
//! `META_FEEDER_STATE_DIR` (default `/data/meta-feeder`), `META_CORE_URL` (D4 //! URL — is read from the persisted `config.json` (dashboard-written) ONLY.
//! self-publish), `RUST_LOG`. //! There is NO env seed for these: a field in the dashboard config schema must
//! Env (tribler source): `TRIBLER_SIDECAR_URL`, `TRIBLER_API_KEY`, //! not have an env var (config from JSON file / web UI is the single source of
//! `TMDB_TOKEN`/`TMDB_LANGUAGE`, plus the enrichment-plugin URLs //! truth).
//! (`FILENAME_PARSER_URL`, `TMDB_PLUGIN_URL`, `META_FEEDER_CALLBACK_URL`). //!
//! Env (infra only): `META_FEEDER_HTTP_LISTEN` (default `0.0.0.0:8080`),
//! `META_FEEDER_STATE_DIR` (default `/data/meta-feeder`), `META_GATEWAY_PEER_ID`,
//! the enrichment-plugin URLs (`FILENAME_PARSER_URL`, `TMDB_PLUGIN_URL`,
//! `META_FEEDER_CALLBACK_URL`), `RUST_LOG`.
use std::net::SocketAddr; use std::net::SocketAddr;
@@ -21,7 +25,7 @@ use meta_feeder_sdk::serve_feeders;
use tracing::info; use tracing::info;
use tracing_subscriber::EnvFilter; use tracing_subscriber::EnvFilter;
use tribler_feeder::tribler::{TriblerConfigFile, TriblerPlugin}; use tribler_feeder::tribler::TriblerPlugin;
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
@@ -35,11 +39,10 @@ async fn main() -> anyhow::Result<()> {
let state_dir = let state_dir =
std::env::var("META_FEEDER_STATE_DIR").unwrap_or_else(|_| "/data/meta-feeder".to_string()); std::env::var("META_FEEDER_STATE_DIR").unwrap_or_else(|_| "/data/meta-feeder".to_string());
// Env is the first-boot seed; the persisted config.json (under the // No env seed: the plugin reads config.json in configure() (sidecar URL,
// per-source cache dir) wins once saved through the dashboard. The tribler // api key, tmdb, meta-core URL) and builds its enrichment/self-publish
// source builds its enrichment driver in configure(). // driver from config.meta_core_url there.
let mut tr = TriblerPlugin::new(); let tr = TriblerPlugin::new();
tr.set_seed_config(TriblerConfigFile::from_env());
let plugins: Vec<Box<dyn FeederPlugin>> = vec![Box::new(tr)]; let plugins: Vec<Box<dyn FeederPlugin>> = vec![Box::new(tr)];
+10 -44
View File
@@ -92,39 +92,11 @@ pub struct TriblerConfigFile {
} }
impl TriblerConfigFile { impl TriblerConfigFile {
/// Parse the config from the env (first-boot seed). Tribler-connection from // NOTE: `TriblerConfigFile::from_env()` was deliberately removed. Tribler
/// `TRIBLER_*`; the enrichment TMDB key/language from `TMDB_TOKEN` // config (sidecar URL, api key, tmdb token/language, meta-core URL) is
/// (or `PROWLARR_TMDB_TOKEN`) / `TMDB_LANGUAGE` — so an operator can still seed // dashboard config — it lives ONLY in the persisted config.json, never in
/// them from env, while the dashboard form overrides at runtime. // env. (Was: TRIBLER_SIDECAR_URL / TRIBLER_API_KEY / TMDB_TOKEN /
pub fn from_env() -> Self { // TMDB_LANGUAGE / META_CORE_URL — all now config-schema fields.)
let mut c = Self::default();
if let Ok(u) = std::env::var("META_CORE_URL") {
if !u.trim().is_empty() {
c.meta_core_url = Some(u.trim().to_string());
}
}
if let Ok(url) = std::env::var("TRIBLER_SIDECAR_URL") {
if !url.trim().is_empty() {
c.sidecar_url = Some(url);
}
}
if let Ok(key) = std::env::var("TRIBLER_API_KEY") {
if !key.trim().is_empty() {
c.api_key = Some(key);
}
}
if let Ok(t) = std::env::var("TMDB_TOKEN").or_else(|_| std::env::var("PROWLARR_TMDB_TOKEN")) {
if !t.trim().is_empty() {
c.tmdb_api_key = Some(t);
}
}
if let Ok(l) = std::env::var("TMDB_LANGUAGE") {
if !l.trim().is_empty() {
c.tmdb_language = Some(l);
}
}
c
}
} }
/// HTTP timeout for the *synchronous* calls (local search, remote-search /// HTTP timeout for the *synchronous* calls (local search, remote-search
@@ -223,9 +195,6 @@ pub struct TriblerPlugin {
sidecar_url: String, sidecar_url: String,
api_key: Option<String>, api_key: Option<String>,
cache: Option<MidhashCache>, cache: Option<MidhashCache>,
/// Env-derived config seed (set by `main` via [`set_seed_config`]).
/// `configure()` applies it when no persisted `config.json` exists.
seed_config: TriblerConfigFile,
/// Effective config snapshot, exposed (redacted) through the SDK config /// Effective config snapshot, exposed (redacted) through the SDK config
/// plane for the dashboard's per-plugin config form. /// plane for the dashboard's per-plugin config form.
cfg: TriblerConfigFile, cfg: TriblerConfigFile,
@@ -261,7 +230,6 @@ impl TriblerPlugin {
sidecar_url, sidecar_url,
api_key: None, api_key: None,
cache: None, cache: None,
seed_config: TriblerConfigFile::default(),
cfg: TriblerConfigFile::default(), cfg: TriblerConfigFile::default(),
enricher: None, enricher: None,
inline_tmdb: crate::enrich::Enricher::new(), inline_tmdb: crate::enrich::Enricher::new(),
@@ -283,11 +251,8 @@ impl TriblerPlugin {
self.api_key = Some(key); self.api_key = Some(key);
} }
/// Install the env-derived seed config (applied by `configure()` when no // set_seed_config was removed: there is no env seed. config.json is the only
/// persisted `config.json` exists). Mirrors the torznab feeder. // config source (dashboard-written); apply_config takes it in configure().
pub fn set_seed_config(&mut self, cfg: TriblerConfigFile) {
self.seed_config = cfg;
}
/// Apply an effective config: override sidecar URL / API key when present, /// Apply an effective config: override sidecar URL / API key when present,
/// otherwise keep the constructor defaults. Records the effective snapshot /// otherwise keep the constructor defaults. Records the effective snapshot
@@ -829,10 +794,12 @@ impl FeederPlugin for TriblerPlugin {
// plane when the operator saves through the dashboard) wins over the env // plane when the operator saves through the dashboard) wins over the env
// seed. Both are optional — tribler has working defaults, so a fully // seed. Both are optional — tribler has working defaults, so a fully
// unconfigured feeder still serves (DEFAULT_SIDECAR_URL, no auth key). // unconfigured feeder still serves (DEFAULT_SIDECAR_URL, no auth key).
// config.json (dashboard-written) is the ONLY config source — no env
// seed. Absent → tribler's built-in defaults (DEFAULT_SIDECAR_URL, no key).
let effective = std::fs::read(cache_dir.join("config.json")) let effective = std::fs::read(cache_dir.join("config.json"))
.ok() .ok()
.and_then(|b| serde_json::from_slice::<TriblerConfigFile>(&b).ok()) .and_then(|b| serde_json::from_slice::<TriblerConfigFile>(&b).ok())
.unwrap_or_else(|| self.seed_config.clone()); .unwrap_or_default();
self.apply_config(effective); self.apply_config(effective);
self.cache = Some(common::open_midhash_cache(cache_dir, "tribler")?); self.cache = Some(common::open_midhash_cache(cache_dir, "tribler")?);
// Build the enrichment driver: infra (META_CORE_URL + plugin URLs + peer // Build the enrichment driver: infra (META_CORE_URL + plugin URLs + peer
@@ -1448,7 +1415,6 @@ fn build_enricher(http: &reqwest::Client, cfg: &TriblerConfigFile) -> Option<Enr
.as_ref() .as_ref()
.map(|s| s.trim().to_string()) .map(|s| s.trim().to_string())
.filter(|s| !s.is_empty()) .filter(|s| !s.is_empty())
.or_else(|| EnrichmentConfig::from_env().map(|c| c.meta_core_url))
.unwrap_or_else(|| meta_feeder_sdk::DEFAULT_META_CORE_URL.to_string()); .unwrap_or_else(|| meta_feeder_sdk::DEFAULT_META_CORE_URL.to_string());
let mut ecfg = EnrichmentConfig::from_meta_core(meta_core_url); let mut ecfg = EnrichmentConfig::from_meta_core(meta_core_url);
if let Some(k) = cfg.tmdb_api_key.as_ref().filter(|s| !s.trim().is_empty()) { if let Some(k) = cfg.tmdb_api_key.as_ref().filter(|s| !s.trim().is_empty()) {