Skip to content

Commit

Permalink
feat: Add reload subcommand to reload configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed May 19, 2022
1 parent 9c8fccd commit a37636d
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,29 @@ async fn main() -> anyhow::Result<()> {
.about("select a CFS scheduler profile")
.arg(clap::arg!([PROFILE])),
)
.subcommand(clap::Command::new("daemon").about("launch the system daemon"))
.subcommand(
clap::Command::new("daemon")
.about("launch the system daemon")
.subcommand(clap::Command::new("reload").about("reload system configuration")),
)
.get_matches();

match matches.subcommand() {
Some(("cpu", cpu_matches)) => cpu(connection, cpu_matches).await,
Some(("daemon", _)) => daemon(connection).await,
Some(("cpu", matches)) => cpu(connection, matches).await,
Some(("daemon", matches)) => daemon(connection, matches).await,
_ => Ok(()),
}
}

async fn reload(connection: Connection) -> anyhow::Result<()> {
dbus::ClientProxy::new(&connection)
.await?
.reload_configuration()
.await?;

Ok(())
}

async fn cpu(connection: Connection, args: &ArgMatches) -> anyhow::Result<()> {
let mut connection = dbus::ClientProxy::new(&connection).await?;

Expand All @@ -85,7 +98,14 @@ async fn cpu(connection: Connection, args: &ArgMatches) -> anyhow::Result<()> {
}

#[allow(clippy::too_many_lines)]
async fn daemon(connection: Connection) -> anyhow::Result<()> {
async fn daemon(connection: Connection, args: &ArgMatches) -> anyhow::Result<()> {
match args.subcommand() {
Some(("reload", _)) => return reload(connection).await,
_ => (),
}

tracing::info!("starting daemon service");

let paths = SchedPaths::new()?;

let upower_proxy = UPowerProxy::new(&connection).await?;
Expand Down

0 comments on commit a37636d

Please # to comment.