feat: with basic server
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-11 15:50:24 +02:00
parent 7d268e73f0
commit 6a147ba0d2
15 changed files with 280 additions and 125 deletions

View File

@@ -0,0 +1,36 @@
use std::{net::SocketAddr, sync::Arc};
use crate::state::{SharedState, State};
mod external_http;
mod internal_http;
mod state;
#[derive(Clone)]
pub struct ServeOptions {
pub external_http: SocketAddr,
pub internal_http: SocketAddr,
}
pub async fn serve(opts: ServeOptions) -> anyhow::Result<()> {
let ctrl_c = async {
tokio::signal::ctrl_c().await.unwrap();
tracing::info!("kill signal received, shutting down");
};
tracing::debug!("setting up dependencies");
let state = SharedState(Arc::new(State::new().await?));
tracing::debug!("serve starting");
tokio::select!(
res = external_http::serve(&state, &opts.external_http) => {
res?
},
res = internal_http::serve(&state, &opts.internal_http) => {
res?
},
() = ctrl_c => {}
);
tracing::debug!("serve finalized");
Ok(())
}