From 6f257c33ef2478224cae448895e1f88b957f80f4 Mon Sep 17 00:00:00 2001 From: Adam Marcus Date: Mon, 2 Sep 2024 16:59:41 -0400 Subject: [PATCH] Make a few errors that new users are likely ot encounter easier to understand --- src/server/server_runner.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/server/server_runner.rs b/src/server/server_runner.rs index 5e2bf7c..d4d656c 100644 --- a/src/server/server_runner.rs +++ b/src/server/server_runner.rs @@ -18,7 +18,7 @@ use actix_web_httpauth::extractors::bearer::BearerAuth; use actix_web_httpauth::middleware::HttpAuthentication; use dyn_clone::clone_box; use std::fs; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; pub fn config(cfg: &mut web::ServiceConfig) { cfg.service(confirm_endpoint); @@ -82,10 +82,12 @@ fn build_cors(ayb_cors: AybConfigCors) -> Cors { pub async fn run_server(config_path: &PathBuf) -> std::io::Result<()> { env_logger::init(); - let ayb_conf = read_config(config_path).unwrap(); + let ayb_conf = read_config(config_path).expect("unable to find an ayb.toml configuration file"); let ayb_conf_for_server = ayb_conf.clone(); - fs::create_dir_all(&ayb_conf.data_path).expect("Unable to create data directory"); - let ayb_db = connect_to_ayb_db(ayb_conf.database_url).await.unwrap(); + fs::create_dir_all(&ayb_conf.data_path).expect("unable to create data directory"); + let ayb_db = connect_to_ayb_db(ayb_conf.database_url) + .await + .expect("unable to connect to ayb database"); let web_details = if let Some(web_conf) = ayb_conf.web { Some( WebFrontendDetails::from_url(&web_conf.info_url) @@ -102,6 +104,12 @@ pub async fn run_server(config_path: &PathBuf) -> std::io::Result<()> { println!("Starting server {}:{}...", ayb_conf.host, ayb_conf.port); if ayb_conf.isolation.is_none() { println!("Note: Server is running without full isolation. Read more about isolating users from one-another: https://github.com/marcua/ayb/#isolation"); + } else { + let isolation = ayb_conf.isolation.unwrap(); + let nsjail_path = Path::new(&isolation.nsjail_path); + if !nsjail_path.exists() { + panic!("nsjail path {} does not exist", nsjail_path.display()); + } } HttpServer::new(move || { let cors = build_cors(ayb_conf.cors.clone());