Private
Public Access
1
0
Files
Kordophone/kordophoned/src/main.rs

47 lines
1.1 KiB
Rust
Raw Normal View History

2025-02-11 23:15:24 -08:00
mod daemon;
mod dbus;
2025-02-11 23:15:24 -08:00
use log::LevelFilter;
use std::future;
2025-02-12 00:32:44 -08:00
use daemon::Daemon;
2025-04-27 22:44:05 -07:00
use dbus::agent::DBusAgent;
2025-02-12 00:32:44 -08:00
2025-02-11 23:15:24 -08:00
fn initialize_logging() {
// Weird: is this the best way to do this?
let log_level = std::env::var("RUST_LOG")
.map(|s| s.parse::<LevelFilter>().unwrap_or(LevelFilter::Info))
.unwrap_or(LevelFilter::Info);
env_logger::Builder::from_default_env()
2025-06-12 18:09:58 -07:00
.format_timestamp_millis()
.filter_level(log_level)
2025-02-11 23:15:24 -08:00
.init();
}
#[tokio::main]
async fn main() {
initialize_logging();
// Create the daemon
let mut daemon = Daemon::new()
.map_err(|e| {
log::error!("Failed to initialize daemon: {}", e);
std::process::exit(1);
})
.unwrap();
// Start the D-Bus agent (events in, signals out).
let agent = DBusAgent::new(daemon.event_sender.clone(), daemon.obtain_signal_receiver());
2025-04-27 22:44:05 -07:00
tokio::spawn(async move {
agent.run().await;
2025-04-27 22:44:05 -07:00
});
// Run the main daemon loop.
daemon.run().await;
// Keep the process alive as long as any background tasks are running.
2025-02-11 23:15:24 -08:00
future::pending::<()>().await;
}