diff --git a/services/arbiter-3.0/src/routes/admin/system.js b/services/arbiter-3.0/src/routes/admin/system.js index e633dba..7fbf85b 100644 --- a/services/arbiter-3.0/src/routes/admin/system.js +++ b/services/arbiter-3.0/src/routes/admin/system.js @@ -15,25 +15,14 @@ router.post('/deploy', (req, res) => { console.log(`[DEPLOY] Deployment initiated by ${username}`); - // Run the deploy script with username for logging - // Script handles its own locking to prevent concurrent deploys - exec(`sudo /opt/scripts/deploy-arbiter.sh "${username}"`, { - timeout: 60000 // 60 second timeout - }, (error, stdout, stderr) => { - if (error) { - console.error(`[DEPLOY] Failed:`, stderr || error.message); - return res.status(500).json({ - success: false, - message: 'Deployment failed', - log: stderr || error.message - }); - } - - console.log(`[DEPLOY] Success:`, stdout); - res.json({ - success: true, - message: stdout.trim() - }); + // Use nohup to detach the process so the response returns before Arbiter restarts + // Output goes to /tmp/deploy.log for debugging if needed + exec(`nohup sudo /opt/scripts/deploy-arbiter.sh "${username}" > /tmp/deploy.log 2>&1 &`); + + // Return immediately - deploy happens in background + res.json({ + success: true, + message: 'Deploy started. Arbiter will restart momentarily.' }); });