1
pub mod config;
2

            
3
pub mod db;
4

            
5
//pub mod transaction;
6
pub mod account;
7
pub mod command;
8
pub mod commodity;
9
pub mod error;
10
pub mod split;
11
pub mod tag;
12
pub mod user;
13
use exitfailure::ExitFailure;
14
use sqlx::any::install_default_drivers;
15
use tokio::{runtime::Handle, task::JoinHandle};
16

            
17
#[macro_use]
18
extern crate rust_i18n;
19

            
20
i18n!("locales", fallback = "en");
21

            
22
async fn boot() -> Result<(), ExitFailure> {
23
    install_default_drivers();
24
    db::migrate_db().await?;
25
    config::load_config().await?;
26

            
27
    log::debug!(
28
        "The initialized: {}",
29
        config::config("initialized").await?.unwrap()
30
    );
31

            
32
    log::info!("{}", &t!("The server boot complete"));
33
    Ok(())
34
}
35

            
36
pub async fn start() -> JoinHandle<Result<(), ExitFailure>> {
37
    let handle = Handle::current();
38

            
39
    handle.spawn(boot())
40
}