1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 21:39:21 +00:00

Can load custom configuration

This commit is contained in:
Pierre HUBERT 2021-02-12 17:35:26 +01:00
parent 13bf916652
commit 05bcbc1f1a

View File

@ -2,12 +2,15 @@ use comunic_server::controllers::server;
use comunic_server::data::config::{conf, Config}; use comunic_server::data::config::{conf, Config};
use comunic_server::helpers::database; use comunic_server::helpers::database;
#[actix_rt::main] #[actix_rt::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
let conf_file = match std::env::args().skip(1).next() {
Some(el) => el,
None => "config.yaml".to_string(),
};
// Load configuration // Load configuration
Config::load("config.yaml").expect("Could not load configuration!"); Config::load(&conf_file).expect("Could not load configuration!");
// Connect to the database // Connect to the database
database::connect(&conf().database).expect("Could not connect to database!"); database::connect(&conf().database).expect("Could not connect to database!");