feat: make network non blocking and fix deploy script
This commit is contained in:
parent
0f0d0513cb
commit
9bc01997d7
2 changed files with 12 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue