From 9a7042df7f9a7ad0324c4442ae918c2a4a442966 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 8 Sep 2024 18:46:43 +0100 Subject: Add framework for separate printer control thread --- crates/web/src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'crates/web/src/main.rs') diff --git a/crates/web/src/main.rs b/crates/web/src/main.rs index f641ce0..d80b232 100644 --- a/crates/web/src/main.rs +++ b/crates/web/src/main.rs @@ -1,17 +1,23 @@ -use axum::{ - http::StatusCode, - routing::{get, post}, - Json, Router, -}; -use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +use axum::{routing::get, Router}; + +pub use argonaut_control::Handle as PrinterThread; +use tracing::info; #[tokio::main(flavor = "current_thread")] async fn main() { tracing_subscriber::fmt::init(); - let app = Router::new().route("/", get(root)); + let printer_thread = PrinterThread::spawn(); + let printer_thread = Arc::new(printer_thread); + let app = Router::new() + .route("/", get(root)) + .with_state(printer_thread); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + + info!("init completed, listening"); axum::serve(listener, app).await.unwrap(); } -- cgit v1.2.3