initial commit

This commit is contained in:
Sampras Lopes
2022-11-16 20:37:50 +05:30
commit 430dcd1967
320 changed files with 64760 additions and 0 deletions

View File

@ -0,0 +1,32 @@
use router::{
configs::settings::{CmdLineConf, Settings},
core::errors::{BachError, BachResult},
logger,
};
use structopt::StructOpt;
#[actix_web::main]
async fn main() -> BachResult<()> {
// get commandline config before initializing config
let cmd_line = CmdLineConf::from_args();
let conf = Settings::with_config_path(cmd_line.config_path).unwrap();
let _guard = logger::setup(&conf.log)?;
logger::info!("Application started [{:?}] [{:?}]", conf.server, conf.log);
let (server, mut state) = router::start_server(conf)
.await
.expect("Failed to create the server");
let _ = server.await;
std::sync::Arc::get_mut(&mut state.store.redis_conn)
.expect("Redis connection pool cannot be closed")
.close_connections()
.await;
Err(BachError::from(std::io::Error::new(
std::io::ErrorKind::Other,
"Server shut down",
)))
}