diff --git a/deploy.sh b/deploy.sh index 5fdd495..2292b4a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -7,6 +7,7 @@ echo "Building for Raspberry Pi..." cross build --release --target aarch64-unknown-linux-gnu echo "Copying to Raspberry Pi..." +ssh noisebridge@noisebell.local "mkdir -p ~/noisebell" scp target/aarch64-unknown-linux-gnu/release/noisebell noisebridge@noisebell.local:~/noisebell/ scp endpoints.json noisebridge@noisebell.local:/home/noisebridge/noisebell/endpoints.json diff --git a/src/main.rs b/src/main.rs index a74537f..618b781 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,9 +61,12 @@ async fn main() -> Result<()> { let server_addr = format!("127.0.0.1:{}", DEFAULT_SERVER_PORT); info!("Starting API server on http://{}", server_addr); - let listener = tokio::net::TcpListener::bind(&server_addr).await?; - axum::serve(listener, app.into_make_service()) - .await?; + let server = tokio::spawn(async move { + let listener = tokio::net::TcpListener::bind(&server_addr).await?; + axum::serve(listener, app.into_make_service()) + .await?; + Ok::<_, anyhow::Error>(()) + }); let callback = move |event: gpio::CircuitEvent| { info!("Circuit state changed: {:?}", event); @@ -81,6 +84,11 @@ async fn main() -> Result<()> { error!("GPIO monitoring error: {}", e); } + // Wait for the server to complete (it shouldn't unless there's an error) + if let Err(e) = server.await? { + error!("Server error: {}", e); + } + Ok(()) }