diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..e9ec8b6 --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,57 @@ +module.exports = { + apps: [ + { + name: "turbotrades-backend", + script: "./index.js", + cwd: "/root/ttbackend", + instances: 1, + exec_mode: "cluster", + autorestart: true, + watch: false, + max_memory_restart: "1G", + env: { + NODE_ENV: "production", + PORT: 3000, + FRONTEND_URL: "https://turbotrades.dev", + BACKEND_URL: "https://api.turbotrades.dev", + WS_URL: "https://ws.turbotrades.dev", + CORS_ORIGIN: "https://turbotrades.dev", + }, + env_production: { + NODE_ENV: "production", + PORT: 3000, + FRONTEND_URL: "https://turbotrades.dev", + BACKEND_URL: "https://api.turbotrades.dev", + WS_URL: "https://ws.turbotrades.dev", + CORS_ORIGIN: "https://turbotrades.dev", + }, + error_file: "/root/ttbackend/logs/pm2-error.log", + out_file: "/root/ttbackend/logs/pm2-out.log", + log_file: "/root/ttbackend/logs/pm2-combined.log", + time: true, + merge_logs: true, + log_date_format: "YYYY-MM-DD HH:mm:ss Z", + min_uptime: "10s", + max_restarts: 10, + restart_delay: 4000, + kill_timeout: 5000, + wait_ready: true, + listen_timeout: 10000, + }, + ], + + deploy: { + production: { + user: "root", + host: "turbotrades.dev", + ref: "origin/main", + repo: "https://git.turbotrades.dev/iDefineHD/TurboTrades.git", + path: "/root/ttbackend", + "post-deploy": + "npm ci --production && cd frontend && npm ci && npm run build && rm -rf /var/www/html/turbotrades/* && cp -r dist/* /var/www/html/turbotrades/ && cd .. && pm2 reload ecosystem.config.js --env production && pm2 save", + "pre-deploy-local": 'echo "Deploying to turbotrades.dev..."', + "post-setup": + "npm install && pm2 start ecosystem.config.js --env production", + }, + }, +};