Add abort execution feature for stuck/running processes
This commit is contained in:
34
server.js
34
server.js
@@ -872,6 +872,40 @@ app.delete('/api/executions/:id', authenticateSSO, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/executions/:id/abort', authenticateSSO, async (req, res) => {
|
||||
try {
|
||||
const executionId = req.params.id;
|
||||
|
||||
// Check if execution exists and is running
|
||||
const [execution] = await pool.query('SELECT status FROM executions WHERE id = ?', [executionId]);
|
||||
|
||||
if (execution.length === 0) {
|
||||
return res.status(404).json({ error: 'Execution not found' });
|
||||
}
|
||||
|
||||
if (execution[0].status !== 'running') {
|
||||
return res.status(400).json({ error: 'Execution is not running' });
|
||||
}
|
||||
|
||||
// Add abort log entry
|
||||
await addExecutionLog(executionId, {
|
||||
action: 'execution_aborted',
|
||||
aborted_by: req.user.username,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
|
||||
// Update execution status to failed
|
||||
await updateExecutionStatus(executionId, 'failed');
|
||||
|
||||
console.log(`[Execution] Execution ${executionId} aborted by ${req.user.username}`);
|
||||
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('[Execution] Error aborting execution:', error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Scheduled Commands API
|
||||
app.get('/api/scheduled-commands', authenticateSSO, async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user