obsidianlog-cli 0.2.1

Long-term, tamper-evident operational log archival on Sia: client-side encrypted, zstd-compressed, hash-chained, and queryable. CLI to serve ingest, query, and verify logs, plus an interactive setup wizard. Installs the `obsidianlog` binary.
Documentation
//! `obsidianlog serve` — run the Vector-compatible HTTP ingest server.
//!
//! Thin wrapper: resolves the config, the encryption key, and the backend
//! (local or Sia — see [`resolve_backend`]), builds an [`ArchiveEngine`], and
//! hands off to `obsidianlog-ingest`, which owns the HTTP server.

use std::path::PathBuf;

use anyhow::{Context, Result};
use obsidianlog_store::ArchiveEngine;
use obsidianlog_store::encrypt::EncryptionKey;

use crate::backend::resolve_backend;
use crate::cli::ServeArgs;
use crate::config::Config;
use crate::keystore;

/// Start the ingest server (blocks until shutdown).
pub fn run(args: ServeArgs, config_path: Option<PathBuf>) -> Result<()> {
    let config = Config::load(config_path.as_deref())?;
    let key = EncryptionKey::new(keystore::load_credential_bundle()?.encryption_key);

    let backend = tokio::runtime::Builder::new_current_thread()
        .enable_all()
        .build()
        .context("starting the backend-resolution runtime")?
        .block_on(resolve_backend(&config))?;

    // Single-writer guard (ADR-0003): for the local backend, fail fast if
    // another obsidianlog process is already serving this data directory,
    // rather than letting both race on manifest.json. Held for the whole
    // server lifetime; released automatically on shutdown.
    let _write_lock = backend
        .acquire_write_lock()
        .context("checking for another obsidianlog process writing to this data directory")?;

    let bind = args.bind.unwrap_or(config.serve.bind);
    let engine = ArchiveEngine::new(backend, key, config.bucket)
        .with_window_secs(config.chunking.window_secs);

    obsidianlog_ingest::serve_engine_blocking(&bind, engine).context("running the ingest server")
}