Updates and bug fixes #2

Merged
jjkiers merged 6 commits from new-rust-zig into main 2023-08-25 21:07:24 +00:00
Showing only changes of commit 483c058105 - Show all commits

View File

@ -7,10 +7,10 @@ use crate::servers::Server;
use log::{debug, error}; use log::{debug, error};
use std::env; use std::env;
use std::path::Path;
fn main() { fn main() {
let config_path = let config_path = find_config();
env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string());
let config = match Config::new(&config_path) { let config = match Config::new(&config_path) {
Ok(config) => config, Ok(config) => config,
@ -27,3 +27,18 @@ fn main() {
let _ = server.run(); let _ = server.run();
error!("Server ended with errors"); error!("Server ended with errors");
} }
fn find_config() -> String {
let config_path =
env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string());
if Path::new(&config_path).exists() {
return config_path;
}
if Path::new("config.yaml").exists() {
return String::from("config.yaml");
}
String::from("")
}