fix(#1052): use systemctl reload nginx instead of systemd-run
This commit is contained in:
parent
637b170cc5
commit
9d11e5b6d6
2 changed files with 12 additions and 43 deletions
|
|
@ -290,48 +290,17 @@ fn reload_gateway_nginx() {
|
||||||
let state = nginx_active_state();
|
let state = nginx_active_state();
|
||||||
let success = match state.as_str() {
|
let success = match state.as_str() {
|
||||||
"active" => {
|
"active" => {
|
||||||
// nginx master is running — SIGHUP is the zero-downtime path.
|
// nginx master is running — ask systemd to reload the unit
|
||||||
// `systemd-run --machine=hive-gateway --quiet --wait --
|
// (SIGHUP to master, zero-downtime worker replacement).
|
||||||
// /run/current-system/sw/bin/nginx -s reload` runs the
|
// `systemctl -M hive-gateway reload nginx` lets systemd
|
||||||
// signal inside the container and exits with the nginx exit
|
// resolve the binary path; avoids the exit-203 (EXEC)
|
||||||
// code. Full binary path required — systemd-run's limited
|
// failure that `systemd-run -- nginx` hit on NixOS where
|
||||||
// PATH misses /run/current-system/sw/bin/. `--` separates
|
// the limited transient-unit PATH misses /run/current-system/sw/bin/.
|
||||||
// systemd-run flags from the command.
|
let ok = gateway_systemctl(&["reload", "nginx"]);
|
||||||
let status = std::process::Command::new("systemd-run")
|
if ok {
|
||||||
.args([
|
tracing::debug!("gateway nginx reload signal sent");
|
||||||
"--machine=hive-gateway",
|
|
||||||
"--quiet",
|
|
||||||
"--wait",
|
|
||||||
"--",
|
|
||||||
// Full path required: systemd-run executes with a
|
|
||||||
// limited PATH that doesn't include NixOS's
|
|
||||||
// /run/current-system/sw/bin/ — plain "nginx" yields
|
|
||||||
// exit 203 (EXEC failure).
|
|
||||||
"/run/current-system/sw/bin/nginx",
|
|
||||||
"-s",
|
|
||||||
"reload",
|
|
||||||
])
|
|
||||||
.status();
|
|
||||||
match status {
|
|
||||||
Ok(s) if s.success() => {
|
|
||||||
tracing::debug!("gateway nginx reload signal sent");
|
|
||||||
true
|
|
||||||
}
|
|
||||||
Ok(s) => {
|
|
||||||
tracing::warn!(
|
|
||||||
exit_code = ?s.code(),
|
|
||||||
"gateway nginx reload exited non-zero — will retry next poll tick"
|
|
||||||
);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
tracing::warn!(
|
|
||||||
error = %e,
|
|
||||||
"failed to invoke systemd-run for gateway nginx reload — will retry"
|
|
||||||
);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ok
|
||||||
}
|
}
|
||||||
"failed" => {
|
"failed" => {
|
||||||
// Unit hit start-limit (e.g. repeated nginx -t failures from
|
// Unit hit start-limit (e.g. repeated nginx -t failures from
|
||||||
|
|
|
||||||
|
|
@ -421,8 +421,8 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# nginx reload is triggered from the HOST side by hive-c0re
|
# nginx reload is triggered from the HOST side by hive-c0re
|
||||||
# via `systemd-run --machine=hive-gateway /run/current-system/sw/bin/nginx -s reload`
|
# via `systemctl -M hive-gateway reload nginx` — lets systemd
|
||||||
# (full path required — systemd-run's limited PATH misses /run/current-system/sw/bin/)
|
# resolve the nginx binary path, avoiding exit-203 EXEC failures.
|
||||||
# after each agents.conf write. A path unit watching the
|
# after each agents.conf write. A path unit watching the
|
||||||
# bind-mounted file inside the container was tried first
|
# bind-mounted file inside the container was tried first
|
||||||
# (A path unit inside the container was tried but IN_MOVED_TO from an atomic rename on the host
|
# (A path unit inside the container was tried but IN_MOVED_TO from an atomic rename on the host
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue