fix(702): narrow SystemdRunMachine to ReloadGatewayNginx in hive-priv
This commit is contained in:
parent
10871381f3
commit
efedfc3ea6
1 changed files with 6 additions and 11 deletions
|
|
@ -243,25 +243,20 @@ async fn exec(req: PrivRequest) -> Result<(String, String)> {
|
|||
Ok((String::new(), String::new()))
|
||||
}
|
||||
|
||||
PrivRequest::SystemdRunMachine { ref machine, ref cmd } => {
|
||||
validate_container_name(machine)?;
|
||||
let mut args = vec!["--machine".to_owned(), machine.clone(), "--quiet".to_owned(), "--".to_owned()];
|
||||
args.extend(cmd.iter().cloned());
|
||||
PrivRequest::ReloadGatewayNginx => {
|
||||
let out = Command::new("systemd-run")
|
||||
.args(&args)
|
||||
.args(["--machine=hive-gateway", "--quiet", "--", "nginx", "-s", "reload"])
|
||||
.output()
|
||||
.await
|
||||
.context("invoke systemd-run")?;
|
||||
let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
|
||||
let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
|
||||
.context("invoke systemd-run for gateway nginx reload")?;
|
||||
if !out.status.success() {
|
||||
bail!(
|
||||
"systemd-run --machine={machine} failed ({}): {}",
|
||||
"gateway nginx reload failed ({}): {}",
|
||||
out.status,
|
||||
stderr.trim()
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
);
|
||||
}
|
||||
Ok((stdout, stderr))
|
||||
Ok((String::new(), String::new()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue