Root cause: server.ts defaults to port 3001 when PORT env var is not set.
PM2 cluster mode shares a single port across all instances, but the PORT
env variable was missing from ecosystem.config.cjs, causing port binding
conflicts.
Fix: Added PORT: '3001' to production API env configuration in
ecosystem.config.cjs. Test environment already had PORT: 3002 set.
Port allocation on projectium.com:
- 3000: Gitea (system)
- 3001: flyer-crawler production
- 3002: flyer-crawler test
- 3003: stock-alert production
- 3004: stock-alert test
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements efficient version synchronization between production and test
environments without running the full test deployment pipeline.
Problem:
- Production version bumps triggered full 5-7 minute test deployment
- Wasteful: 95% less CPU, 99.8% less file I/O needed
- Code already tested when originally pushed to main
Solution (matching stock-alert architecture):
- New sync-test-version.yml workflow (~30 seconds)
- Triggers automatically after successful production deployment
- Updates only package.json in test directory
- Restarts PM2 with --update-env to refresh version metadata
Benefits:
- 90% faster (30 sec vs 5-7 min)
- Saves ~20 minutes/month of CI time
- Clean separation: no conditionals polluting deploy-to-test.yml
- Same end state, optimized path
Changes:
- Added .gitea/workflows/sync-test-version.yml (new workflow)
- Added docs/adr/0062-lightweight-version-sync-workflow.md (decision record)
- Updated docs/adr/index.md (ADR catalog)
- Cleaned up duplicate TSOA generation step in deploy-to-test.yml
Architecture:
- deploy-to-test.yml: unchanged (runs on code changes)
- deploy-to-prod.yml: unchanged (no explicit trigger needed)
- sync-test-version.yml: auto-triggers via workflow_run
Related:
- Inspired by stock-alert project optimization (commit 021f9c8)
- ADR-061: PM2 Process Isolation Safeguards
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
CRITICAL FIX: Production deployment was failing because tsoa-spec.json
is a gitignored generated file that was missing on the server.
Root cause:
- server.ts imports './src/config/tsoa-spec.json' (line 30)
- File is generated by TSOA but gitignored
- Deployment workflows never ran 'npm run tsoa:build'
- Server crashed on startup with ERR_MODULE_NOT_FOUND
Changes:
- Add "Generate TSOA OpenAPI Spec and Routes" step to:
- deploy-to-prod.yml
- deploy-to-test.yml
- manual-deploy-major.yml
- Runs after 'npm ci' but before React build
- Generates both tsoa-spec.json and tsoa-generated routes
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>