Checkpoint

This commit is contained in:
2026-08-02 18:30:34 +00:00
parent 596af4ed80
commit 6c33bcfb27
41 changed files with 6360 additions and 1 deletions
+58
View File
@@ -0,0 +1,58 @@
use anyhow::Context;
use clap::Parser;
use tokio::signal;
use tokio::task::JoinSet;
use tracing_subscriber::EnvFilter;
use crate::args::Args;
use crate::commands::setup::SetupKind;
mod args;
mod commands;
mod db;
mod listener;
mod utils;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let args = Args::parse();
let user_id = uzers::get_current_uid();
if user_id != 0 {
anyhow::bail!(concat!(
"The daemon must be run as root, but the current user is not root. ",
"Please run the daemon as root."
));
}
let env_filter = if args.debug {
EnvFilter::new("off,nye_daemon=trace,nye_wire_protocol=trace")
} else {
EnvFilter::new("off,nye_daemon=info,nye_wire_protocol=warn")
};
tracing_subscriber::fmt()
.with_env_filter(env_filter)
.with_target(false)
.init();
commands::setup::setup(SetupKind::System)
.await
.context("Could not set up the Nye package manager's system-wide configuration.")?;
let mut tasks = JoinSet::new();
tokio::select! {
_ = listener::run(&mut tasks) => {}
_ = signal::ctrl_c() => {
tasks.join_all().await;
}
}
listener::cleanup()
.await
.context("Failed to cleanup socket listener.")?;
Ok(())
}