mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-13 09:52:00 -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 clap::Parser;
|
||||
|
||||
use steamos_manager::{root, user};
|
||||
use steamos_manager::daemon;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
|
@ -21,8 +21,8 @@ struct Args {
|
|||
pub async fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
if args.root {
|
||||
root::daemon().await
|
||||
daemon::root().await
|
||||
} else {
|
||||
user::daemon().await
|
||||
daemon::user().await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,13 @@ use zbus::connection::Connection;
|
|||
use crate::sls::{LogLayer, LogReceiver};
|
||||
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<()>>,
|
||||
token: CancellationToken,
|
||||
sigterm: Signal,
|
||||
|
@ -25,7 +31,7 @@ pub struct 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,
|
||||
connection: Connection,
|
||||
) -> Result<Daemon> {
|
||||
|
@ -51,13 +57,13 @@ impl 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();
|
||||
self.services
|
||||
.spawn(async move { service.start(token).await });
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) -> Result<()> {
|
||||
pub(crate) async fn run(&mut self) -> Result<()> {
|
||||
ensure!(
|
||||
!self.services.is_empty(),
|
||||
"Can't run a daemon with no services attached."
|
|
@ -15,7 +15,6 @@ use tokio_util::sync::CancellationToken;
|
|||
use tracing::{info, warn};
|
||||
|
||||
mod cec;
|
||||
mod daemon;
|
||||
mod ds_inhibit;
|
||||
mod error;
|
||||
mod hardware;
|
||||
|
@ -26,9 +25,8 @@ mod sls;
|
|||
mod systemd;
|
||||
mod user_manager;
|
||||
|
||||
pub mod daemon;
|
||||
pub mod proxy;
|
||||
pub mod root;
|
||||
pub mod user;
|
||||
pub mod wifi;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue