summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2022-09-06 23:15:09 +0200
committerNyaaori <+@nyaaori.cat>2022-10-10 13:25:01 +0200
commit057f8364cc317dc8646043abd6c8ff3ef759625f (patch)
treef80bf450aa962947ab2651376768e021113a7ef6 /src/main.rs
parent82e7f57b389d011bc8d80f9142f723b3cd1e1ad2 (diff)
downloadconduit-057f8364cc317dc8646043abd6c8ff3ef759625f.zip
fix: some compile time errors
Only 174 errors left!
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs71
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 {