2026-07-14 20:10:29 +02:00
|
|
|
//! 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;
|
2026-07-15 09:51:57 +02:00
|
|
|
pub mod discovery;
|
2026-07-15 08:07:24 +02:00
|
|
|
pub mod dscp;
|
2026-07-14 20:47:11 +02:00
|
|
|
pub mod meta;
|
2026-07-15 08:07:24 +02:00
|
|
|
pub mod metered;
|
2026-07-14 20:10:29 +02:00
|
|
|
pub mod server;
|
2026-07-14 22:27:58 +02:00
|
|
|
pub mod shaped;
|
2026-07-14 20:47:11 +02:00
|
|
|
pub mod store;
|
2026-07-14 21:18:25 +02:00
|
|
|
pub mod transfer;
|
2026-07-14 20:10:29 +02:00
|
|
|
|
2026-07-14 20:47:11 +02:00
|
|
|
use anyhow::Result;
|
2026-07-14 20:10:29 +02:00
|
|
|
|
|
|
|
|
/// Run a daemon with the given config until the future is dropped or the
|
2026-07-14 20:47:11 +02:00
|
|
|
/// listener fails. The socket is bound before the accept loop starts, so
|
|
|
|
|
/// once this future has been polled the socket path exists.
|
2026-07-14 20:10:29 +02:00
|
|
|
pub async fn run(config: config::Config) -> Result<()> {
|
2026-07-14 20:47:11 +02:00
|
|
|
let socket_path = config.socket_path.clone();
|
2026-07-14 22:27:58 +02:00
|
|
|
let daemon = daemon::Daemon::open(config).await?;
|
2026-07-14 20:47:11 +02:00
|
|
|
let listener = server::bind_socket(&socket_path)?;
|
2026-07-14 20:10:29 +02:00
|
|
|
server::serve(listener, daemon).await
|
|
|
|
|
}
|