fix(#1329): restart hive-matrix-daemon after token write so new credential is picked up immediately
This commit is contained in:
parent
92b32d06fb
commit
f201f04d4e
4 changed files with 52 additions and 0 deletions
|
|
@ -337,6 +337,28 @@ async fn exec(req: PrivRequest, writer: &mut OwnedWriteHalf) -> Result<(String,
|
|||
validate_agent_name(agent_name)?;
|
||||
write_agent_state_file(agent_name, "matrix-token", &format!("{token}\n"))
|
||||
}
|
||||
|
||||
PrivRequest::RestartMatrixDaemon { ref agent_name } => {
|
||||
validate_agent_name(agent_name)?;
|
||||
let machine = format!("--machine=h-{agent_name}");
|
||||
let unit = "hive-matrix-daemon.service";
|
||||
let out = Command::new("systemctl")
|
||||
.args([&machine, "restart", unit])
|
||||
.output()
|
||||
.await
|
||||
.with_context(|| format!("systemctl restart {unit} in container h-{agent_name}"))?;
|
||||
if !out.status.success() {
|
||||
bail!(
|
||||
"systemctl restart {unit} in h-{agent_name} exited {}: {}",
|
||||
out.status,
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
);
|
||||
}
|
||||
Ok((
|
||||
String::from_utf8_lossy(&out.stdout).into_owned(),
|
||||
String::from_utf8_lossy(&out.stderr).into_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue