Skip to content

Commit

Permalink
Make a few errors that new users are likely ot encounter easier to un…
Browse files Browse the repository at this point in the history
…derstand (#455)
  • Loading branch information
marcua committed Sep 2, 2024
1 parent c59226d commit 918d870
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/server/server_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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());
Expand Down

0 comments on commit 918d870

Please sign in to comment.