feat: support in-page upgrade for git-clone deployments - #2319
Open
kosmo888 wants to merge 2 commits into
Open
Conversation
The old upgrade.sh killed the server process and started a new one with nohup. When the Web UI is managed by systemd with Restart=always, killing the process causes systemd to immediately restart the old version while the new nohup process fights for the same port. Fix: - Detect systemd service name and use systemctl restart instead - Keep a non-systemd fallback (kill + nohup) for bare-metal deploys - Stash local changes before git pull to avoid merge failures - Add automatic rollback on build/start failure - Derive WEBUI_DIR from script location instead of hardcoding
The Web UI update button only worked for npm global install deployments (npm install -g hermes-web-ui@latest). Users running from a git clone with systemd could not upgrade from the page — clicking update either silently updated the wrong npm package or did nothing useful. Changes: - health.ts: detect git-clone deployment by checking for .git directory, check for updates via git fetch + git show origin/main:package.json instead of npm registry. Expose is_git_clone in health response. - update.ts: add git-clone upgrade path in handleUpdate that runs git stash, git pull, npm install, npm run build, then restarts via systemctl (when running under systemd) or falls back to spawn-restart. - system.ts: add is_git_clone field to HealthResponse type. The npm global install path is preserved as fallback for non-git deploys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Web UI "Update" button only works for npm global install deployments (
npm install -g hermes-web-ui@latest). Users running from a git clone with systemd cannot upgrade from the page:handleUpdaterunsnpm install -g hermes-web-ui@latest— this installs to/usr/lib/node_modules/, but the systemd service runs from the git clone directory (dist/server/index.js). The running server never picks up the change.hermes-web-ui restart) targets the npm-installed CLI, not the git-clone processResult: clicking "Update" in the sidebar appears to succeed, but the running server is never actually updated. The user has no way to upgrade from the page.
Fix
health.ts.gitdirectory relative to the server module locationgit fetch origin main && git show origin/main:package.json) instead of the npm registry when in a git-clone deploymentis_git_clone: booleanin the health response so the frontend can show appropriate messagingupdate.tsrunGitUpdateInstall(): stashes local changes, runsgit pull origin main,npm install --include=dev,npm run buildspawnGitRestart(): detects systemd service via cgroup inspection and usessystemctl restart, falling back to the existing spawn-restart mechanismhandleUpdate: checksisGitCloneDeployment()first and routes to the git upgrade path; falls back to the original npm global install path for non-git deploymentssystem.ts(client)is_git_clone?: booleantoHealthResponseinterfaceHow it works (git-clone deployment)
Test Plan
isGitCloneDeployment()returnstruewhen.gitexists,falsein Docker and npm installsis_git_clone: truefor git-clone deploysgit fetchcorrectly detects newer versions onorigin/mainhandleUpdateon git-clone deploy runsgit pull + npm install + npm run buildsystemctl restartwhen under systemdnpm install -gpath