Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a few errors that new users are likely ot encounter easier to understand #455

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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