mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 17:32:21 -04:00
daemon: Improve module naming
This commit is contained in:
parent
5efb67f15c
commit
dc7de16137
5 changed files with 14 additions and 10 deletions
|
@ -8,7 +8,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use steamos_manager::{root, user};
|
use steamos_manager::daemon;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
@ -21,8 +21,8 @@ struct Args {
|
||||||
pub async fn main() -> Result<()> {
|
pub async fn main() -> Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
if args.root {
|
if args.root {
|
||||||
root::daemon().await
|
daemon::root().await
|
||||||
} else {
|
} else {
|
||||||
user::daemon().await
|
daemon::user().await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,13 @@ use zbus::connection::Connection;
|
||||||
use crate::sls::{LogLayer, LogReceiver};
|
use crate::sls::{LogLayer, LogReceiver};
|
||||||
use crate::{reload, Service};
|
use crate::{reload, Service};
|
||||||
|
|
||||||
pub struct Daemon {
|
mod root;
|
||||||
|
mod user;
|
||||||
|
|
||||||
|
pub use root::daemon as root;
|
||||||
|
pub use user::daemon as user;
|
||||||
|
|
||||||
|
pub(crate) struct Daemon {
|
||||||
services: JoinSet<Result<()>>,
|
services: JoinSet<Result<()>>,
|
||||||
token: CancellationToken,
|
token: CancellationToken,
|
||||||
sigterm: Signal,
|
sigterm: Signal,
|
||||||
|
@ -25,7 +31,7 @@ pub struct Daemon {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Daemon {
|
impl Daemon {
|
||||||
pub async fn new<S: SubscriberExt + Send + Sync + for<'a> LookupSpan<'a>>(
|
pub(crate) async fn new<S: SubscriberExt + Send + Sync + for<'a> LookupSpan<'a>>(
|
||||||
subscriber: S,
|
subscriber: S,
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
) -> Result<Daemon> {
|
) -> Result<Daemon> {
|
||||||
|
@ -51,13 +57,13 @@ impl Daemon {
|
||||||
Ok(daemon)
|
Ok(daemon)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_service<S: Service + 'static>(&mut self, service: S) {
|
pub(crate) fn add_service<S: Service + 'static>(&mut self, service: S) {
|
||||||
let token = self.token.clone();
|
let token = self.token.clone();
|
||||||
self.services
|
self.services
|
||||||
.spawn(async move { service.start(token).await });
|
.spawn(async move { service.start(token).await });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run(&mut self) -> Result<()> {
|
pub(crate) async fn run(&mut self) -> Result<()> {
|
||||||
ensure!(
|
ensure!(
|
||||||
!self.services.is_empty(),
|
!self.services.is_empty(),
|
||||||
"Can't run a daemon with no services attached."
|
"Can't run a daemon with no services attached."
|
|
@ -15,7 +15,6 @@ use tokio_util::sync::CancellationToken;
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
mod cec;
|
mod cec;
|
||||||
mod daemon;
|
|
||||||
mod ds_inhibit;
|
mod ds_inhibit;
|
||||||
mod error;
|
mod error;
|
||||||
mod hardware;
|
mod hardware;
|
||||||
|
@ -26,9 +25,8 @@ mod sls;
|
||||||
mod systemd;
|
mod systemd;
|
||||||
mod user_manager;
|
mod user_manager;
|
||||||
|
|
||||||
|
pub mod daemon;
|
||||||
pub mod proxy;
|
pub mod proxy;
|
||||||
pub mod root;
|
|
||||||
pub mod user;
|
|
||||||
pub mod wifi;
|
pub mod wifi;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue