generated from Patagia/template-nix
Compare commits
1 commit
9eafef92a9
...
b163f329af
Author | SHA1 | Date | |
---|---|---|---|
b163f329af |
1 changed files with 12 additions and 13 deletions
|
@ -1,13 +1,12 @@
|
|||
use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Serialize;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use trace_request::trace_request;
|
||||
|
||||
use systemd_ipc::addrs::SYSTEMD_HOSTNAME;
|
||||
use systemd_ipc::io_systemd_hostname::{self, VarlinkClientInterface};
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::context::ControllerContext;
|
||||
|
||||
/// Version and build information
|
||||
|
@ -25,19 +24,19 @@ struct MachineInfo {
|
|||
pub async fn describe(
|
||||
rqctx: RequestContext<Arc<ControllerContext>>,
|
||||
) -> Result<HttpResponseOk<MachineInfo>, HttpError> {
|
||||
// Connect to systemd.Hostname
|
||||
// Make it tokio task blocking
|
||||
tokio::task::block_in_place(move || {
|
||||
let machine_info = tokio::task::spawn_blocking(move || {
|
||||
// Connect to systemd.Hostname
|
||||
let conn = varlink::Connection::with_address(SYSTEMD_HOSTNAME).unwrap();
|
||||
let mut sd = io_systemd_hostname::VarlinkClient::new(conn);
|
||||
|
||||
let machine_id = sd.describe().call().unwrap().MachineID;
|
||||
|
||||
tracing::info_span!("Hello, span hostd!");
|
||||
|
||||
tracing::info!(monotonic_counter.version_calls = 1);
|
||||
|
||||
let machine_info = MachineInfo { machine_id };
|
||||
|
||||
Ok(HttpResponseOk(machine_info))
|
||||
MachineInfo { machine_id }
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
tracing::info_span!("Hello, span hostd!");
|
||||
|
||||
tracing::info!(monotonic_counter.version_calls = 1);
|
||||
Ok(HttpResponseOk(machine_info))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue