diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-03-20 22:46:53 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-03-20 22:46:53 -0500 |
commit | e95e9506a30736876a7598c30c018af51256f1ff (patch) | |
tree | 33c01bc7228f40bd7616085cc58a93fc948a22f7 /zoned/src/main.rs | |
parent | 2d377920fd2b624a2a58a051607152ab324a8614 (diff) |
feat: implement pty over websocket
Diffstat (limited to 'zoned/src/main.rs')
-rw-r--r-- | zoned/src/main.rs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/zoned/src/main.rs b/zoned/src/main.rs index 019c9e0..f275e7a 100644 --- a/zoned/src/main.rs +++ b/zoned/src/main.rs @@ -1,14 +1,15 @@ +use anyhow::Context; use axum::extract::Extension; use figment::{ providers::{Env, Format, Serialized, Toml}, Figment, }; use std::{net::SocketAddr, sync::Arc}; -use tracing::{debug, error}; +use tracing::info; use zoned::{build_routes, Config, State}; #[tokio::main] -async fn main() { +async fn main() -> Result<(), zoned::Error> { tracing_subscriber::fmt::init(); let figment = Figment::from(Serialized::defaults(Config::default())) @@ -17,26 +18,22 @@ async fn main() { let config = match Config::try_from(figment) { Ok(config) => config, - Err(err) => { - error!("{}", err); - std::process::exit(1) - } + Err(err) => return Err(err), }; + let addr = SocketAddr::from((config.ip_address, config.port)); + let shared_state = match State::try_from(config) { - Ok(state) => Arc::new(state), - Err(err) => { - error!("{}", err); - std::process::exit(1) - } + Ok(config) => Arc::new(config), + Err(err) => return Err(err), }; let routes = build_routes().layer(Extension(shared_state)); - let addr = SocketAddr::from(([172, 21, 110, 173], 3001)); - debug!("listening on {}", addr); + info!("listening on {}", addr); axum::Server::bind(&addr) .serve(routes.into_make_service()) .await - .unwrap(); + .context("Axum error") + .map_err(zoned::Error::from) } |