fix: resolve Hetzner deploy failures — bash syntax error, PM2 start, JWT_SECRET crash loop#161
Merged
Merged
Conversation
… JWT_SECRET, native modules Agent-Logs-Url: https://github.com/ruffy80/ZeusAI/sessions/cda0ab7e-02ba-42b6-8b5c-17664c7b023b Co-authored-by: ruffy80 <29306714+ruffy80@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
ruffy80
April 13, 2026 22:28
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Three consecutive deploys (#52–54) failed at bash parse time; backend
unicornprocess also crash-loops on the server (1909+ restarts visible in run #51 logs).Root causes & fixes
deploy-hetzner.yml— bash syntax error (critical, breaks all recent deploys)Unclosed
if [ -d client ] && [ -f client/package.json ]; then(no matchingfi) causedbash: syntax error: unexpected end of filebefore any command executed. Also removed straycd "$DEPLOY_PATH" && npm run lint && npm testlines that would fail since rootpackage.jsonhas nolint/testscripts.deploy-hetzner.yml— PM2 "Process 0 not found"pm2 startOrRestart ecosystem.config.jstries to restart processes by saved dump IDs. Whenunicorn(id 0) isn't in the current PM2 daemon list, it silently skips it — backend never starts. Replaced withpm2 stop all && pm2 delete all && pm2 start. Now resolvesecosystem.config.jsfrom both repo-root (UNICORN_FINAL/ecosystem.config.js) and UNICORN_FINAL-as-root (ecosystem.config.js) deploy layouts.fix-server.sh— JWT_SECRET not validated in existing.envbackend/index.jscallsprocess.exit(1)in production ifJWT_SECRETis empty or equals"unicorn-jwt-secret-change-in-prod". Script previously only checked file existence, not secret validity. Now extracts and validates the value; generates and writes a new random secret if missing or default.Native module ABI mismatch
Added
npm rebuild better-sqlite3afternpm installin both the deploy workflow andfix-server.shto handle Node.js version drift between bootstrap and runtime.Health check diagnostics
Increased sleep before health check (5s → 15s in deploy, 3s → 10s in fix-server.sh). Both now print
pm2 logs unicornautomatically when the backend is unreachable, surfacing crash reasons in CI output without requiring manual SSH access.