-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathmain.rs
More file actions
42 lines (34 loc) · 1.27 KB
/
main.rs
File metadata and controls
42 lines (34 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::env;
use payments_poller::{config::Config, db::Db, payments::PaymentsPoller};
use tracing_subscriber::{EnvFilter, FmtSubscriber};
fn read_config_filepath_from_args() -> String {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
panic!(
"You must provide a config file. Usage: {} <config-file-path>",
args[0]
);
}
args[1].clone()
}
#[tokio::main]
async fn main() {
let filter = EnvFilter::new("info,sp1_cuda=warn");
let subscriber = FmtSubscriber::builder().with_env_filter(filter).finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
let config_file_path = read_config_filepath_from_args();
tracing::info!("Loading config from {}...", config_file_path);
let config = Config::from_file(&config_file_path).expect("Config is valid");
tracing::info!("Config loaded");
let db = Db::try_new(&config.db_connection_url)
.await
.expect("db to start");
let payments_poller = match PaymentsPoller::new(db, config) {
Ok(poller) => poller,
Err(err) => {
tracing::error!("Failed to create Payments Poller: {err:?}");
return;
}
};
payments_poller.start().await;
}