Skip to content

fix: resolve Hetzner deploy failures — bash syntax error, PM2 start, JWT_SECRET crash loop#161

Merged
ruffy80 merged 1 commit into
mainfrom
copilot/check-hertzner-server-status
Apr 13, 2026
Merged

fix: resolve Hetzner deploy failures — bash syntax error, PM2 start, JWT_SECRET crash loop#161
ruffy80 merged 1 commit into
mainfrom
copilot/check-hertzner-server-status

Conversation

Copilot AI commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Three consecutive deploys (#52–54) failed at bash parse time; backend unicorn process 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 matching fi) caused bash: syntax error: unexpected end of file before any command executed. Also removed stray cd "$DEPLOY_PATH" && npm run lint && npm test lines that would fail since root package.json has no lint/test scripts.

deploy-hetzner.yml — PM2 "Process 0 not found"

pm2 startOrRestart ecosystem.config.js tries to restart processes by saved dump IDs. When unicorn (id 0) isn't in the current PM2 daemon list, it silently skips it — backend never starts. Replaced with pm2 stop all && pm2 delete all && pm2 start. Now resolves ecosystem.config.js from 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 .env

backend/index.js calls process.exit(1) in production if JWT_SECRET is 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-sqlite3 after npm install in both the deploy workflow and fix-server.sh to 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 unicorn automatically when the backend is unreachable, surfacing crash reasons in CI output without requiring manual SSH access.

… 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>
@vercel

vercel Bot commented Apr 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zeusai Ready Ready Preview, Comment Apr 13, 2026 10:28pm

Request Review

@ruffy80 ruffy80 marked this pull request as ready for review April 13, 2026 22:28
@ruffy80 ruffy80 merged commit d0683ed into main Apr 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants