1
#![recursion_limit = "256"]
2

            
3
pub mod config;
4

            
5
pub mod db;
6

            
7
//pub mod transaction;
8
pub mod account;
9
pub mod command;
10
pub mod commodity;
11
pub mod error;
12
#[cfg(feature = "scripting")]
13
pub mod script;
14
#[cfg(feature = "scripting")]
15
pub mod script_mgmt;
16
pub mod split;
17
pub mod tag;
18
pub mod user;
19
use exitfailure::ExitFailure;
20
use sqlx::any::install_default_drivers;
21
use tokio::{runtime::Handle, task::JoinHandle};
22

            
23
#[macro_use]
24
extern crate rust_i18n;
25

            
26
i18n!("locales", fallback = "en");
27

            
28
async fn boot() -> Result<(), ExitFailure> {
29
    install_default_drivers();
30
    db::migrate_db().await?;
31
    config::load_config().await?;
32

            
33
    log::debug!(
34
        "The initialized: {}",
35
        config::config("initialized").await?.unwrap()
36
    );
37

            
38
    log::info!("{}", &t!("The server boot complete"));
39
    Ok(())
40
}
41

            
42
pub async fn start() -> JoinHandle<Result<(), ExitFailure>> {
43
    let handle = Handle::current();
44

            
45
    handle.spawn(boot())
46
}