refactor: centralize port config + fix 8082 conflict
- Add EMBED_URL, OLLAMA_URL, LLM_HEALTH_URL to config.rs - Fix health.rs hardcoded ports → config references - Fix sync_db.rs Ollama URL → config::OLLAMA_URL - Create config/port_registry.tsv (single source of truth for ports) - Remove Caddy 8082 proxy block (port belongs to LLM) - Fix .env LLM_URL: localhost → 127.0.0.1 (avoid IPv6 Caddy conflict)
This commit is contained in:
@@ -73,7 +73,7 @@ REDIS_CACHE_TTL_VIDEO_META=3600
|
|||||||
TMDB_API_KEY=e9cde52197f6f8df4d9db99da93db1fb
|
TMDB_API_KEY=e9cde52197f6f8df4d9db99da93db1fb
|
||||||
MOMENTRY_TMDB_PROBE_ENABLED=true
|
MOMENTRY_TMDB_PROBE_ENABLED=true
|
||||||
# LLM for 5W1H summary (points to M5 Gemma4)
|
# LLM for 5W1H summary (points to M5 Gemma4)
|
||||||
MOMENTRY_LLM_SUMMARY_URL=http://localhost:8082/v1/chat/completions
|
MOMENTRY_LLM_SUMMARY_URL=http://127.0.0.1:8082/v1/chat/completions
|
||||||
MOMENTRY_LLM_SUMMARY_MODEL=google_gemma-4-26B-A4B-it-Q5_K_M.gguf
|
MOMENTRY_LLM_SUMMARY_MODEL=google_gemma-4-26B-A4B-it-Q5_K_M.gguf
|
||||||
MOMENTRY_LLM_SUMMARY_ENABLED=true
|
MOMENTRY_LLM_SUMMARY_ENABLED=true
|
||||||
|
|
||||||
|
|||||||
22
config/port_registry.tsv
Normal file
22
config/port_registry.tsv
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Port Registry - Momentry Core
|
||||||
|
# Each port must have exactly one owner.
|
||||||
|
# Before adding a service: pick a free port, add a row here, then configure.
|
||||||
|
#
|
||||||
|
# Port Service Owner Config Key Default Source
|
||||||
|
22 ssh sshd - - macOS
|
||||||
|
80 http Caddy - - Caddyfile
|
||||||
|
443 https Caddy - - Caddyfile
|
||||||
|
2019 caddy-admin Caddy - - Caddyfile (internal)
|
||||||
|
3000 gitea gitea - 3000 start_momentry.sh
|
||||||
|
3002 production momentry MOMENTRY_SERVER_PORT 3002 run-server-3002.sh
|
||||||
|
3003 playground momentry_playground MOMENTRY_SERVER_PORT 3003 start_momentry.sh
|
||||||
|
3200 dashboard Caddy - - Caddyfile
|
||||||
|
3306 mariadb mariadbd - 3306 start_momentry.sh
|
||||||
|
5432 postgresql postgres DATABASE_URL postgres://...:5432 start_momentry.sh
|
||||||
|
6379 redis redis-server REDIS_URL redis://...:6379 start_momentry.sh
|
||||||
|
6333 qdrant qdrant QDRANT_URL http://...:6333 start_momentry.sh
|
||||||
|
8081 wordpress Caddy - - Caddyfile
|
||||||
|
8082 llm llama-server MOMENTRY_LLM_CHAT_URL http://...:8082 start_momentry.sh
|
||||||
|
9000 php-fpm php-fpm - 9000 brew services
|
||||||
|
11434 ollama ollama MOMENTRY_OLLAMA_URL http://...:11434 start_momentry.sh
|
||||||
|
11436 embedding embeddinggemma MOMENTRY_EMBED_URL http://...:11436 start_momentry.sh
|
||||||
|
@@ -375,9 +375,9 @@ async fn health_detailed(State(state): State<AppState>) -> Json<DetailedHealthRe
|
|||||||
.output()
|
.output()
|
||||||
.map(|o| o.status.success())
|
.map(|o| o.status.success())
|
||||||
.unwrap_or(false),
|
.unwrap_or(false),
|
||||||
embedding_server: check_http("http://127.0.0.1:11436/health").await,
|
embedding_server: check_http(&format!("{}/health", config::EMBED_URL.as_str())).await,
|
||||||
gdino_api: check_http("http://127.0.0.1:8080/health").await,
|
gdino_api: check_http("http://127.0.0.1:8080/health").await,
|
||||||
llm: check_http("http://127.0.0.1:8082/health").await,
|
llm: check_http(config::LLM_HEALTH_URL.as_str()).await,
|
||||||
rsync: check_rsync().await,
|
rsync: check_rsync().await,
|
||||||
watcher_running: check_process_running("watcher"),
|
watcher_running: check_process_running("watcher"),
|
||||||
worker_running: check_process_running("worker"),
|
worker_running: check_process_running("worker"),
|
||||||
|
|||||||
@@ -132,6 +132,19 @@ pub static SYSTEM_TIMEZONE: Lazy<String> = Lazy::new(|| {
|
|||||||
pub static MONGODB_DATABASE: Lazy<String> =
|
pub static MONGODB_DATABASE: Lazy<String> =
|
||||||
Lazy::new(|| env::var("MONGODB_DATABASE").unwrap_or_else(|_| "momentry".to_string()));
|
Lazy::new(|| env::var("MONGODB_DATABASE").unwrap_or_else(|_| "momentry".to_string()));
|
||||||
|
|
||||||
|
pub static EMBED_URL: Lazy<String> =
|
||||||
|
Lazy::new(|| env::var("MOMENTRY_EMBED_URL").unwrap_or_else(|_| "http://localhost:11436".to_string()));
|
||||||
|
|
||||||
|
pub static OLLAMA_URL: Lazy<String> =
|
||||||
|
Lazy::new(|| env::var("MOMENTRY_OLLAMA_URL").unwrap_or_else(|_| "http://localhost:11434".to_string()));
|
||||||
|
|
||||||
|
/// LLM health endpoint derived from CHAT_URL.
|
||||||
|
/// e.g. "http://127.0.0.1:8082/v1/chat/completions" → "http://127.0.0.1:8082/health"
|
||||||
|
pub static LLM_HEALTH_URL: Lazy<String> = Lazy::new(|| {
|
||||||
|
let chat = llm::CHAT_URL.clone();
|
||||||
|
chat.trim_end_matches("/v1/chat/completions").to_string() + "/health"
|
||||||
|
});
|
||||||
|
|
||||||
pub static QDRANT_COLLECTION: Lazy<String> =
|
pub static QDRANT_COLLECTION: Lazy<String> =
|
||||||
Lazy::new(|| env::var("QDRANT_COLLECTION").unwrap_or_else(|_| "momentry_rule1".to_string()));
|
Lazy::new(|| env::var("QDRANT_COLLECTION").unwrap_or_else(|_| "momentry_rule1".to_string()));
|
||||||
|
|
||||||
@@ -234,15 +247,11 @@ pub mod llm {
|
|||||||
|
|
||||||
/// Vision LLM endpoint (frame analysis, OCR). Can be same as CHAT_URL or different.
|
/// Vision LLM endpoint (frame analysis, OCR). Can be same as CHAT_URL or different.
|
||||||
/// Default: falls back to CHAT_URL
|
/// Default: falls back to CHAT_URL
|
||||||
pub static VISION_URL: Lazy<String> = Lazy::new(|| {
|
pub static VISION_URL: Lazy<String> =
|
||||||
env::var("MOMENTRY_LLM_VISION_URL")
|
Lazy::new(|| env::var("MOMENTRY_LLM_VISION_URL").unwrap_or_else(|_| CHAT_URL.clone()));
|
||||||
.unwrap_or_else(|_| CHAT_URL.clone())
|
|
||||||
});
|
|
||||||
|
|
||||||
pub static VISION_MODEL: Lazy<String> = Lazy::new(|| {
|
pub static VISION_MODEL: Lazy<String> =
|
||||||
env::var("MOMENTRY_LLM_VISION_MODEL")
|
Lazy::new(|| env::var("MOMENTRY_LLM_VISION_MODEL").unwrap_or_else(|_| CHAT_MODEL.clone()));
|
||||||
.unwrap_or_else(|_| CHAT_MODEL.clone())
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Text summary LLM endpoint (5W1H, story). Can be same as CHAT_URL or different.
|
/// Text summary LLM endpoint (5W1H, story). Can be same as CHAT_URL or different.
|
||||||
pub static SUMMARY_URL: Lazy<String> = Lazy::new(|| {
|
pub static SUMMARY_URL: Lazy<String> = Lazy::new(|| {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ impl SyncDb {
|
|||||||
pub async fn embed_text(&self, text: &str) -> Result<Vec<f32>> {
|
pub async fn embed_text(&self, text: &str) -> Result<Vec<f32>> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let response = client
|
let response = client
|
||||||
.post("http://localhost:11434/api/embeddings")
|
.post(&format!("{}/api/embeddings", crate::core::config::OLLAMA_URL.as_str()))
|
||||||
.json(&serde_json::json!({
|
.json(&serde_json::json!({
|
||||||
"model": "all-minilm",
|
"model": "all-minilm",
|
||||||
"prompt": text,
|
"prompt": text,
|
||||||
|
|||||||
Reference in New Issue
Block a user