feat: schema tracking, SHA256 integrity, identity UUID fix, 3-angle face match, cuts table, trace stranger_id
This commit is contained in:
@@ -65,6 +65,19 @@ struct UserInfo {
|
||||
|
||||
// Global State
|
||||
static SERVER_START: OnceCell<Instant> = OnceCell::new();
|
||||
static SERVER_HOST: OnceCell<String> = OnceCell::new();
|
||||
static SERVER_PORT: OnceCell<u16> = OnceCell::new();
|
||||
|
||||
fn get_host() -> String {
|
||||
SERVER_HOST
|
||||
.get()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "0.0.0.0".to_string())
|
||||
}
|
||||
|
||||
fn get_port() -> u16 {
|
||||
SERVER_PORT.get().copied().unwrap_or(0)
|
||||
}
|
||||
|
||||
fn get_uptime_ms() -> u64 {
|
||||
SERVER_START
|
||||
@@ -75,6 +88,8 @@ fn get_uptime_ms() -> u64 {
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct HealthResponse {
|
||||
ip: String,
|
||||
port: u16,
|
||||
status: String,
|
||||
version: String,
|
||||
build_git_hash: String,
|
||||
@@ -462,6 +477,8 @@ pub struct AppState {
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct DetailedHealthResponse {
|
||||
ip: String,
|
||||
port: u16,
|
||||
status: String,
|
||||
version: String,
|
||||
build_git_hash: String,
|
||||
@@ -583,6 +600,8 @@ async fn health(State(state): State<AppState>) -> Json<HealthResponse> {
|
||||
}
|
||||
|
||||
Json(HealthResponse {
|
||||
ip: get_host(),
|
||||
port: get_port(),
|
||||
status: status.to_string(),
|
||||
version: env!("BUILD_VERSION").to_string(),
|
||||
build_git_hash: env!("BUILD_GIT_HASH").to_string(),
|
||||
@@ -677,6 +696,8 @@ async fn health_detailed(State(state): State<AppState>) -> Json<DetailedHealthRe
|
||||
};
|
||||
|
||||
Json(DetailedHealthResponse {
|
||||
ip: get_host(),
|
||||
port: get_port(),
|
||||
status: overall_status.to_string(),
|
||||
version: env!("BUILD_VERSION").to_string(),
|
||||
build_git_hash: env!("BUILD_GIT_HASH").to_string(),
|
||||
@@ -3014,6 +3035,31 @@ async fn unregister(
|
||||
|
||||
pub async fn start_server(host: &str, port: u16) -> anyhow::Result<()> {
|
||||
let _ = SERVER_START.set(Instant::now());
|
||||
// Resolve actual IP address for health identification
|
||||
let resolved_ip = if host == "0.0.0.0" {
|
||||
// Try to find a non-loopback IP
|
||||
if let Ok(addrs) = std::net::ToSocketAddrs::to_socket_addrs(&"localhost:0") {
|
||||
if let Some(addr) = addrs.filter_map(|a| match a {
|
||||
std::net::SocketAddr::V4(v4) if !v4.ip().is_loopback() => Some(v4.ip().to_string()),
|
||||
_ => None,
|
||||
}).next() {
|
||||
addr
|
||||
} else {
|
||||
// Fallback: try getting IP from UDP socket
|
||||
std::net::UdpSocket::bind("0.0.0.0:0")
|
||||
.and_then(|s| s.connect("8.8.8.8:53").map(|_| s))
|
||||
.and_then(|s| s.local_addr())
|
||||
.map(|a| a.ip().to_string())
|
||||
.unwrap_or_else(|_| "0.0.0.0".to_string())
|
||||
}
|
||||
} else {
|
||||
host.to_string()
|
||||
}
|
||||
} else {
|
||||
host.to_string()
|
||||
};
|
||||
let _ = SERVER_HOST.set(resolved_ip);
|
||||
let _ = SERVER_PORT.set(port);
|
||||
|
||||
let embedder = std::sync::Arc::new(Embedder::new("nomic-embed-text-v2-moe:latest".to_string()));
|
||||
let mongo_cache = MongoCache::init().await?;
|
||||
|
||||
Reference in New Issue
Block a user