Fix deploy button: use detached process to avoid 502 on self-restart

This commit is contained in:
Claude
2026-04-09 19:48:04 +00:00
parent ef562ef59a
commit 02bddc0baf

View File

@@ -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.'
});
});