feat(config): use an environment variable for config file path

This commit is contained in:
orhun 2021-07-24 20:51:08 +03:00
parent ee760529a3
commit 411f278656
No known key found for this signature in database
GPG Key ID: F83424824B3E4B90
1 changed files with 3 additions and 1 deletions

View File

@ -2,6 +2,7 @@ use actix_web::middleware::Logger;
use actix_web::{App, HttpServer};
use rustypaste::config::Config;
use rustypaste::server;
use std::env;
use std::fs;
use std::io::Result as IoResult;
@ -9,7 +10,8 @@ use std::io::Result as IoResult;
async fn main() -> IoResult<()> {
dotenv::dotenv().ok();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
let config = Config::parse("config").expect("failed to parse config");
let config = Config::parse(env::var("CONFIG").as_deref().unwrap_or("config"))
.expect("failed to parse config");
let server_config = config.server.clone();
fs::create_dir_all(server_config.upload_path)?;
let mut http_server = HttpServer::new(move || {