Updates and bug fixes #2
19
src/main.rs
19
src/main.rs
@ -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("")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user