aboutsummaryrefslogtreecommitdiffstats
path: root/crates/daemon/src/main.rs
blob: 1966e113427b81b29781f3bf45ec138ce9f6718a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#![expect(unused_crate_dependencies, reason = "Didn't remove them yet")]

use clap::Parser;
use eyre::{Result, WrapErr};
use std::path::PathBuf;
use turtle_daemon::aclient::{
    database::ClientSqlite, record::sqlite_store::SqliteStore, settings::Settings,
};
use turtle_daemon::api::client::{Probe, probe};

#[derive(Parser, Debug)]
#[command(infer_subcommands = true)]
pub(crate) enum Cmd {
    /// Start the daemon server
    Start {
        /// Also write daemon logs to the console (useful for debugging)
        #[arg(long)]
        show_logs: bool,
    },
}

#[tokio::main]
async fn main() -> Result<()> {
    let settings = Settings::new().wrap_err("could not load client settings")?;
    let db_path = PathBuf::from(settings.db_path.as_str());
    let record_store_path = PathBuf::from(settings.record_store_path.as_str());

    let history_db = ClientSqlite::new(db_path, settings.local_timeout).await?;
    let sqlite_store = SqliteStore::new(record_store_path, settings.local_timeout).await?;

    match Cmd::parse() {
        Cmd::Start { show_logs, .. } => {
            turtle_daemon::boot(settings, sqlite_store, history_db).await
        }
    }
}