Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ impl Controller {
"thread_count": status.thread_count,
"manual_scaling_sticky": status.manual_scaling_sticky,
"scaling_allowed": status.scaling_allowed,
"alive": status.alive,
"vcpu_count": status.vcpu_count,
"per_thread_util": status.per_thread_util,
// FIXME omit if status.perf.is_none()?
Expand Down
3 changes: 2 additions & 1 deletion src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ pub async fn run(cfg: Config, backends: Vec<Box<dyn Backend>>) -> Result<(), Dae
tracing::info!(target: "controller", added, "initial discovery");

let (dbus_tx, mut dbus_rx) = tokio::sync::mpsc::channel(1);
let _dbus_connection = dbus::serve(dbus::Service::new(dbus_tx)).await?;
let service = dbus::Service::new(dbus_tx);
let _dbus_connection = dbus::serve(service).await?;
let mut inotify_events = setup_inotify(&backends)?;
let mut poll = interval(Duration::from_secs_f64(cfg.scale_poll_secs));
poll.set_missed_tick_behavior(MissedTickBehavior::Skip);
Expand Down
16 changes: 15 additions & 1 deletion src/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,22 @@ impl Service {

/// Spin the D-Bus service on the well-known name / object path
/// backed by `service` and drive replies from the controller mpsc.
///
/// Component tests set `IO_THREAD_CONTROLLER_DBUS_ADDRESS` to use their
/// private bus; production leaves it unset and uses the system bus.
pub async fn serve(service: Service) -> Result<zbus::Connection, zbus::Error> {
let conn = zbus::connection::Builder::system()?
let builder = match std::env::var("IO_THREAD_CONTROLLER_DBUS_ADDRESS") {
Ok(address) => zbus::connection::Builder::address(address.as_str())?,
Err(_) => zbus::connection::Builder::system()?,
};
serve_with(builder, service).await
}

async fn serve_with(
builder: zbus::connection::Builder<'_>,
service: Service,
) -> Result<zbus::Connection, zbus::Error> {
let conn = builder
.name(DBUS_BUS_NAME)?
.serve_at(DBUS_OBJECT_PATH, service)?
.build()
Expand Down
Loading