1
#![recursion_limit = "256"]
2

            
3
pub mod auth_keys;
4
pub mod bootstrap;
5
pub mod config;
6

            
7
pub mod db;
8

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

            
26
#[macro_use]
27
extern crate rust_i18n;
28

            
29
i18n!("locales", fallback = "en");
30

            
31
/// Runs the one-time-per-DB boot sequence: install sqlx drivers, migrate the
32
/// admin DB, run the idempotent global seed (`seed_complete`-guarded), and load
33
/// config. Every startup path MUST call this before reading config — the web
34
/// binary calls it directly; the CLI/server path goes through [`start`]. Safe
35
/// to call on an already-booted DB (migrate + seed are idempotent).
36
pub async fn boot() -> Result<(), ExitFailure> {
37
    install_default_drivers();
38
    db::migrate_db().await?;
39
    bootstrap::seed().await?;
40
    config::load_config().await?;
41

            
42
    log::info!("{}", &t!("The server boot complete"));
43
    Ok(())
44
}
45

            
46
pub async fn start() -> JoinHandle<Result<(), ExitFailure>> {
47
    let handle = Handle::current();
48

            
49
    handle.spawn(boot())
50
}