Files
javis_bot/app/src/main.rs
javis-bot 5c510bb602 feat(app): start Strata from the data folder and point the brain at it
M5 step 4, second part. The services start the LLM first: the installed
Strata with the M0 kit's model and normal placement (models in
models/llm, parallel 1, or 2 when a chat channel answers every message,
pictures off, --restart), wait until /v1/models lists the model, and stop
it last. The first start downloads the model; the dashboard shows
Strata's last line and percentage, and stop also cancels a start (the
server is cleared). llm.url uses a server the app does not start.

On every start the app writes config/brain.json (Strata's /v1, the
listed model id, memory/jarvis.db) and hands it to the worker as
JARVIS_CONFIG_PATH. Loading a config with its own db_path no longer
creates ~/.local/share/jarvis.

service_start/service_restart run in the background. Settings gain
llm.context and llm.port (model screen) and llm.url (file only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:45:38 +09:00

44 lines
1.6 KiB
Rust

//! Jarvis app (headless until the Tauri GUI arrives in M5): jarvis-app <data folder>
//! The data folder can also come from JARVIS_DATA_DIR; the bot token from the stored secrets, else
//! JARVIS_DISCORD_TOKEN. The services run through the same controller the dashboard uses.
use jarvis_app::control::{Controller, ServicesHost};
use jarvis_app::error_log;
#[tokio::main]
async fn main() {
let data_dir = std::env::args().nth(1).or_else(|| std::env::var("JARVIS_DATA_DIR").ok());
let Some(data_dir) = data_dir else {
error_log!("app", "usage: jarvis-app <data folder> (or set JARVIS_DATA_DIR)");
std::process::exit(2);
};
let data_dir = std::path::PathBuf::from(data_dir);
// The log hub: daily files in <data folder>/logs, stored secrets masked in exports.
let logs_dir = data_dir.join("logs");
let _ = std::fs::create_dir_all(&logs_dir);
let hub = jarvis_app::logs::LogHub::new(Some(&logs_dir));
hub.set_secrets(jarvis_app::secrets::Secrets::new(&data_dir.join("config").join("secrets.dat")).values());
jarvis_app::logs::install(hub);
let controller = Controller::new(ServicesHost::new(data_dir));
if controller.start().await.is_err() {
std::process::exit(1);
}
shutdown_signal().await;
let _ = controller.stop().await;
}
async fn shutdown_signal() {
#[cfg(unix)]
{
let mut term = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("signal");
tokio::select! {
_ = tokio::signal::ctrl_c() => {}
_ = term.recv() => {}
}
}
#[cfg(not(unix))]
{
let _ = tokio::signal::ctrl_c().await;
}
}