This repository has been archived on 2026-08-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
varde/varde-daemon/src/lib.rs
T

24 lines
870 B
Rust
Raw Normal View History

//! varde-daemon library surface.
//!
//! The daemon is a binary, but its internals are exposed as a library so
//! integration tests can run real daemons in-process on ephemeral sockets.
pub mod config;
pub mod daemon;
pub mod server;
use std::sync::Arc;
use anyhow::{Context, Result};
/// Run a daemon with the given config until the future is dropped or the
/// listener fails. Binds the socket before returning control to the
/// runtime so callers can rely on it existing once this future is polled.
pub async fn run(config: config::Config) -> Result<()> {
std::fs::create_dir_all(&config.store_dir)
.with_context(|| format!("creating store directory {}", config.store_dir.display()))?;
let listener = server::bind_socket(&config.socket_path)?;
let daemon = Arc::new(daemon::Daemon::new(config));
server::serve(listener, daemon).await
}