Skip to content

Commit bb6d47a

Browse files
author
Paul C
committed
v24.7.10: upgrader — survive the console tab closing before the post-install restart fires
Sponsor report (PapaSchlumpf, 2026-05-25): upgrading from 24.7.7 to 24.7.9 via the in-app console finishes the install but the dashboard still shows the OLD version on every node. Closing the upgrade console tab leaves the node at 24.7.7. ## Root cause setup.sh ends with: nohup bash -c "sleep 3 && systemctl restart wolfstack" \ >/dev/null 2>&1 & The 3-second sleep gives the operator time to read the "**** UPGRADE COMPLETE ****" + "Please Refresh your browser…" lines before the service blinks. But the upgrade console is a pty spawned by WolfStack itself; when the operator closes the browser tab, the websocket closes, the pty is torn down, and every child in the pty session is signalled. `nohup` only ignores SIGHUP — SIGTERM/SIGKILL from cgroup teardown or session cleanup still land. If the operator closes the tab within the 3 seconds, the pending restart dies with the pty. The new binary is on disk; the service keeps running the old one. Dashboard stays at 24.7.7. PapaSchlumpf's screenshot shows the script reached "UPGRADE COMPLETE" and "Please Refresh your browser if upgrading…" — exactly the moment a reasonable operator closes the tab, before the 3-second restart fires. ## Fix Schedule the restart via a transient systemd timer so it's owned by PID 1, not our pty shell. `systemd-run --on-active=3s` creates a one-shot transient timer that fires in 3 seconds independently of whatever spawned it — closing the browser tab cannot kill it. Fallback for hosts without systemd-run (containers, minimal images): `setsid bash -c "sleep 3 && systemctl restart wolfstack" </dev/null >/dev/null 2>&1 &` — `setsid` puts the child in a new session detached from the pty's controlling terminal, the best a plain shell can do. Applied to both setup.sh (the canonical installer) and ibmsetup.sh (the IBM Cloud variant). Both are fetched fresh from GitHub `master` by the upgrade console on every run, so once this commit is on master the very next upgrade attempt picks up the fix — PapaSchlumpf doesn't need to do anything manual to recover, just re-run the upgrade from the console. ## Safety * `bash -n setup.sh` and `bash -n ibmsetup.sh` parse clean. * `cargo build` clean (2 pre-existing dead-code warnings unrelated). * If `systemd-run` itself fails for any reason (e.g. dbus down), the `||` falls back to `setsid` — same outcome as today, minus the SIGHUP immunity that nohup provided. setsid is strictly stronger than nohup against pty teardown. * The new binary is already on disk before the restart logic runs; if neither path fires the service, the operator's existing fallback ("sudo systemctl restart wolfstack" printed in the Manage section above) still works. ## Operator recovery PapaSchlumpf can re-run the upgrade from the console — the 24.7.7 binary fetches a fresh setup.sh from master on every run, so the fixed restart path kicks in immediately.
1 parent a31825e commit bb6d47a

3 files changed

Lines changed: 47 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wolfstack"
3-
version = "24.7.9"
3+
version = "24.7.10"
44
edition = "2024"
55
authors = ["Wolf Software Systems Ltd"]
66
description = "Server management platform for the Wolf software suite"

ibmsetup.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,21 @@ echo ""
12731273
echo "Please Refresh your browser if upgrading..."
12741274

12751275
# ─── Restart service if upgrading (must be last!) ────────────────────────────
1276+
#
1277+
# See setup.sh for the rationale. PapaSchlumpf 2026-05-25:
1278+
# closing the upgrade-console browser tab before the sleep
1279+
# elapsed killed the pending restart along with the pty.
1280+
# systemd-run is owned by PID 1, so the restart survives.
12761281
if [ "$RESTART_SERVICE" = "true" ]; then
1277-
nohup bash -c "sleep 3 && systemctl restart wolfstack" &>/dev/null &
1282+
if command -v systemd-run >/dev/null 2>&1; then
1283+
systemd-run --quiet --no-block \
1284+
--on-active=3s \
1285+
--unit="wolfstack-self-restart-$$.timer" \
1286+
/bin/systemctl restart wolfstack >/dev/null 2>&1 || \
1287+
setsid bash -c "sleep 3 && systemctl restart wolfstack" \
1288+
</dev/null >/dev/null 2>&1 &
1289+
else
1290+
setsid bash -c "sleep 3 && systemctl restart wolfstack" \
1291+
</dev/null >/dev/null 2>&1 &
1292+
fi
12781293
fi

setup.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2176,6 +2176,35 @@ echo ""
21762176
echo "Please Refresh your browser if upgrading..."
21772177

21782178
# ─── Restart service if upgrading (must be last!) ────────────────────────────
2179+
#
2180+
# Detach properly. PapaSchlumpf 2026-05-25: upgrading from 24.7.7 to
2181+
# 24.7.9 via the in-app console, closing the browser tab before the
2182+
# 3-second sleep elapsed killed the pending restart along with the
2183+
# pty session — the new binary was installed but the service kept
2184+
# running the old one, so the dashboard kept showing 24.7.7.
2185+
#
2186+
# `nohup ... &` is NOT enough. The console session is a pty spawned
2187+
# by wolfstack itself; when the browser closes, wolfstack tears down
2188+
# the pty and every child in its session/cgroup is signalled. `nohup`
2189+
# only ignores SIGHUP, not SIGTERM/SIGKILL that come from cgroup
2190+
# cleanup. Schedule via a transient systemd timer so the restart is
2191+
# owned by PID 1 and cannot be killed by the pty closing.
2192+
#
2193+
# Fallback (no systemd-run) uses `setsid` to start a new session
2194+
# detached from the pty plus full stdio redirection — the best a
2195+
# plain shell can do.
21792196
if [ "$RESTART_SERVICE" = "true" ]; then
2180-
nohup bash -c "sleep 3 && systemctl restart wolfstack" >/dev/null 2>&1 &
2197+
if command -v systemd-run >/dev/null 2>&1; then
2198+
# Transient one-shot timer owned by systemd; survives the pty
2199+
# closing because its parent is PID 1, not our shell.
2200+
systemd-run --quiet --no-block \
2201+
--on-active=3s \
2202+
--unit="wolfstack-self-restart-$$.timer" \
2203+
/bin/systemctl restart wolfstack >/dev/null 2>&1 || \
2204+
setsid bash -c "sleep 3 && systemctl restart wolfstack" \
2205+
</dev/null >/dev/null 2>&1 &
2206+
else
2207+
setsid bash -c "sleep 3 && systemctl restart wolfstack" \
2208+
</dev/null >/dev/null 2>&1 &
2209+
fi
21812210
fi

0 commit comments

Comments
 (0)