Add sync test using AI

This commit is contained in:
2025-09-09 21:02:37 +02:00
parent 8b1a9be8c2
commit 4e38b13faa
10 changed files with 2766 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
mod controllers;
mod routes;
mod utils;
mod sync;
use anyhow::Result;
use axum::{
@@ -15,10 +16,14 @@ use tower_http::{
services::{ServeDir, ServeFile},
};
use utils::init_database;
use sync::{SyncServer, server::SyncServerConfig};
#[tokio::main]
async fn main() -> Result<()> {
let pool = init_database().await?;
let sync_pool = pool.clone();
let api_routes = Router::new()
.route("/setup/status", get(setup::get_setup_status))
.route("/setup/init", post(setup::init_setup))
@@ -51,8 +56,18 @@ async fn main() -> Result<()> {
println!("Warning: dist directory not found at {}", dist_path);
}
let sync_config = SyncServerConfig::default();
let sync_server = SyncServer::new(sync_config.clone(), sync_pool);
tokio::spawn(async move {
if let Err(e) = sync_server.start().await {
eprintln!("Sync server error: {}", e);
}
});
let listener = tokio::net::TcpListener::bind("0.0.0.0:8379").await?;
println!("Server running on http://0.0.0.0:8379");
println!("HTTP server running on http://0.0.0.0:8379");
println!("Sync server running on {}:{}", sync_config.bind_address, sync_config.port);
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())