mirror of
https://github.com/perstarkse/minne.git
synced 2026-06-25 11:26:17 +02:00
chore: harden common storage bootstrap and slim embedded db assets
Unify embedding config, build providers from system settings, and fail startup when index builds error or time out. Move Surreal assets under common/db so embeds exclude crate source, and read storage via streams.
This commit is contained in:
+13
-35
@@ -1,47 +1,25 @@
|
||||
mod bootstrap;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use api_router::{api_routes_v1, api_state::ApiState};
|
||||
use axum::{extract::FromRef, Router};
|
||||
use common::storage::types::system_settings::SystemSettings;
|
||||
use html_router::{
|
||||
html_routes,
|
||||
html_state::{HtmlState, StateResources},
|
||||
use axum::extract::FromRef;
|
||||
use bootstrap::{
|
||||
init, prepare_embedding_runtime,
|
||||
wiring::{build_api_state, build_html_state, minne_routes},
|
||||
};
|
||||
use tracing::info;
|
||||
|
||||
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let services = bootstrap::init().await?;
|
||||
let services = init().await?;
|
||||
prepare_embedding_runtime(&services).await?;
|
||||
|
||||
let session_store = Arc::new(services.db.create_session_store().await?);
|
||||
let html_state = build_html_state(&services).await?;
|
||||
let api_state = build_api_state(&services);
|
||||
|
||||
let (_settings, _dimensions_changed) =
|
||||
SystemSettings::sync_from_embedding_provider(&services.db, &services.embedding_provider)
|
||||
.await?;
|
||||
|
||||
let html_state = HtmlState::new_with_resources(StateResources {
|
||||
db: Arc::clone(&services.db),
|
||||
openai_client: Arc::clone(&services.openai_client),
|
||||
session_store,
|
||||
storage: services.storage.clone(),
|
||||
config: services.config.clone(),
|
||||
reranker_pool: services.reranker_pool.clone(),
|
||||
embedding_provider: Arc::clone(&services.embedding_provider),
|
||||
template_engine: None,
|
||||
let app = minne_routes(&api_state, &html_state).with_state(AppState {
|
||||
api_state,
|
||||
html_state,
|
||||
});
|
||||
|
||||
let api_state = ApiState::new(&services.config, services.storage).await?;
|
||||
|
||||
let app = Router::new()
|
||||
.nest("/api/v1", api_routes_v1(&api_state))
|
||||
.merge(html_routes(&html_state))
|
||||
.with_state(AppState {
|
||||
api_state,
|
||||
html_state,
|
||||
});
|
||||
|
||||
info!(
|
||||
"Starting server listening on 0.0.0.0:{}",
|
||||
services.config.http_port
|
||||
@@ -55,6 +33,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
#[derive(Clone, FromRef)]
|
||||
struct AppState {
|
||||
api_state: ApiState,
|
||||
html_state: HtmlState,
|
||||
api_state: api_router::api_state::ApiState,
|
||||
html_state: html_router::html_state::HtmlState,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user