Update 2024 #1

Open
mtrx wants to merge 11 commits from update-2024 into main
2 changed files with 11 additions and 5 deletions
Showing only changes of commit a5001ab732 - Show all commits

View file

@ -7,7 +7,6 @@ services:
- 8000:8000
hostname: crablog
container_name: crablog
env_file: ./crablog.env
restart: unless-stopped
volumes:
- ./content:/app/content

View file

@ -21,7 +21,14 @@ pub struct Accounts {
}
fn load_config() -> Config {
dotenv().expect(".env file not found");
match dotenv() {
Ok(_) => {
println!(".env exists, loading environment variables.")
}
Err(_) => {
println!(".env does not exist, possibly the docker image is run which requires to set environment variables manually.")
}
}
// return config value or panic if not set
fn eval_required_conf(variable_name: String) -> String {
@ -31,7 +38,7 @@ fn load_config() -> Config {
return value;
}
Err(_) => {
panic!("{} not set!", variable_name)
panic!("Environment variable '{}' not set!", variable_name)
}
}
}
@ -45,11 +52,11 @@ fn load_config() -> Config {
}
Err(_) => match default_value {
Some(val) => {
println!("Variable {variable_name} not set. Using default value: {val}.");
println!("Environment variable '{variable_name}' not set. Using default value: {val}.");
return Some(String::from(val));
}
None => {
println!("Variable {variable_name} not set. No default, leaving this empty.");
println!("Environment variable '{variable_name}' not set. No default, leaving this empty.");
None
}
},