runs, but not webserver

This commit is contained in:
2026-01-22 17:57:52 -07:00
parent feda48b0a4
commit ce7ce427c6
5 changed files with 91 additions and 40 deletions

View File

@@ -3,14 +3,41 @@ mod state;
mod utils;
use bot::ProtosBot;
use std::sync::{Arc, Mutex};
use state::game_state::GameState;
use std::sync::{Arc, Mutex};
fn main() {
println!("Starting RustBot...");
let game_state = Arc::new(Mutex::new(GameState::default()));
rsbwapi::start(move |_game| ProtosBot::new(game_state.clone() ));
// // Start the webserver in a separate thread
// std::thread::spawn(|| {
// let rt = tokio::runtime::Runtime::new().unwrap();
// rt.block_on(start_webserver());
// });
rsbwapi::start(move |_game| ProtosBot::new(game_state.clone()));
}
async fn start_webserver() {
use axum::Router;
use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use protoss_bot_web::App;
let conf = get_configuration(None).await.unwrap();
let leptos_options = conf.leptos_options;
let addr = leptos_options.site_addr;
let routes = generate_route_list(App);
let app = Router::new()
.leptos_routes(&leptos_options, routes, App)
.with_state(leptos_options);
println!("Web server listening on http://{}", &addr);
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}