mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
initial commit
This commit is contained in:
32
crates/router/src/bin/router.rs
Normal file
32
crates/router/src/bin/router.rs
Normal 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",
|
||||
)))
|
||||
}
|
||||
Reference in New Issue
Block a user