diff options
author | Timo Kösters <timo@koesters.xyz> | 2022-09-06 23:15:09 +0200 |
---|---|---|
committer | Nyaaori <+@nyaaori.cat> | 2022-10-10 13:25:01 +0200 |
commit | 057f8364cc317dc8646043abd6c8ff3ef759625f (patch) | |
tree | f80bf450aa962947ab2651376768e021113a7ef6 /src/main.rs | |
parent | 82e7f57b389d011bc8d80f9142f723b3cd1e1ad2 (diff) | |
download | conduit-057f8364cc317dc8646043abd6c8ff3ef759625f.zip |
fix: some compile time errors
Only 174 errors left!
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/src/main.rs b/src/main.rs index a1af976..543b953 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,47 +46,44 @@ use tikv_jemallocator::Jemalloc; #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; -lazy_static! { - static ref DB: Database = { - let raw_config = - Figment::new() - .merge( - Toml::file(Env::var("CONDUIT_CONFIG").expect( - "The CONDUIT_CONFIG env var needs to be set. Example: /etc/conduit.toml", - )) - .nested(), - ) - .merge(Env::prefixed("CONDUIT_").global()); - - let config = match raw_config.extract::<Config>() { - Ok(s) => s, - Err(e) => { - eprintln!("It looks like your config is invalid. The following error occured while parsing it: {}", e); - std::process::exit(1); - } - }; - - config.warn_deprecated(); - - let db = match Database::load_or_create(&config).await { - Ok(db) => db, - Err(e) => { - eprintln!( - "The database couldn't be loaded or created. The following error occured: {}", - e - ); - std::process::exit(1); - } - }; - }; -} - #[tokio::main] async fn main() { - lazy_static::initialize(&DB); + // Initialize DB + let raw_config = + Figment::new() + .merge( + Toml::file(Env::var("CONDUIT_CONFIG").expect( + "The CONDUIT_CONFIG env var needs to be set. Example: /etc/conduit.toml", + )) + .nested(), + ) + .merge(Env::prefixed("CONDUIT_").global()); + + let config = match raw_config.extract::<Config>() { + Ok(s) => s, + Err(e) => { + eprintln!("It looks like your config is invalid. The following error occured while parsing it: {}", e); + std::process::exit(1); + } + }; + + config.warn_deprecated(); + + let db = match KeyValueDatabase::load_or_create(&config).await { + Ok(db) => db, + Err(e) => { + eprintln!( + "The database couldn't be loaded or created. The following error occured: {}", + e + ); + std::process::exit(1); + } + }; + + SERVICES.set(db).expect("this is the first and only time we initialize the SERVICE static"); let start = async { - run_server(&config).await.unwrap(); + run_server().await.unwrap(); }; if config.allow_jaeger { |