fix: correct service paths, nohup removal, MongoDB graceful fallback, add MariaDB + Caddy to startup
- Fix Qdrant binary path (services/ -> momentry_resources/bin/) - Fix LLM binary/model paths (llama/ -> momentry_resources/llama/, models/ -> models/llm/) - Fix PostgreSQL data path (pgsql/data -> momentry/var/postgresql) - Remove nohup (fails in LaunchDaemon environment) - Add MongoDB graceful fallback with 5s timeout in server.rs - Add MariaDB + Caddy steps to startup script for WordPress - Revert all unrelated changes
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use axum::Router;
|
||||
use tokio::time::timeout;
|
||||
use tower_http::cors::{Any, CorsLayer};
|
||||
|
||||
use crate::core::cache::{MongoCache, RedisCache};
|
||||
@@ -30,7 +33,21 @@ pub async fn start_server(host: &str, port: u16) -> anyhow::Result<()> {
|
||||
health::init_server_state(host, port);
|
||||
|
||||
let embedder = std::sync::Arc::new(Embedder::new("nomic-embed-text-v2-moe:latest".to_string()));
|
||||
let mongo_cache = MongoCache::init().await?;
|
||||
|
||||
// MongoDB is ONLY a cache layer — if unavailable, the server continues
|
||||
// with Redis cache alone. This keeps both 3002 and 3003 bootable
|
||||
// without requiring MongoDB to be installed or running.
|
||||
let mongo_cache = match timeout(Duration::from_secs(5), MongoCache::init()).await {
|
||||
Ok(Ok(cache)) => cache,
|
||||
Ok(Err(e)) => {
|
||||
tracing::warn!("MongoDB cache unavailable (continuing without): {e}");
|
||||
MongoCache::disabled().await
|
||||
}
|
||||
Err(_) => {
|
||||
tracing::warn!("MongoDB init timed out (continuing without cache)");
|
||||
MongoCache::disabled().await
|
||||
}
|
||||
};
|
||||
let redis_cache = RedisCache::new()?;
|
||||
let db = PostgresDb::init().await?;
|
||||
|
||||
|
||||
19
src/core/cache/mongo_cache.rs
vendored
19
src/core/cache/mongo_cache.rs
vendored
@@ -80,6 +80,25 @@ impl MongoCache {
|
||||
Ok(cache)
|
||||
}
|
||||
|
||||
/// Create a disabled cache instance — all ops are no-ops (is_enabled() = false).
|
||||
/// Used when MongoDB is unavailable; Redis cache continues independently.
|
||||
pub async fn disabled() -> Self {
|
||||
let client = Client::with_uri_str("mongodb://localhost:27017")
|
||||
.await
|
||||
.expect("disabled mongo client (lazy — no actual connect)");
|
||||
let db = client.database("disabled_cache");
|
||||
Self {
|
||||
client,
|
||||
db: db.clone(),
|
||||
collection: db.collection("disabled"),
|
||||
settings: CacheSettings {
|
||||
enabled: false,
|
||||
..Default::default()
|
||||
},
|
||||
initialized: Arc::new(RwLock::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
async fn ensure_indexes(&self) -> Result<()> {
|
||||
let mut guard = self.initialized.write().await;
|
||||
if *guard {
|
||||
|
||||
Reference in New Issue
Block a user