feat: add endpoints for task cancellation and dispatcher control
This commit is contained in:
@@ -1092,6 +1092,31 @@ app.post('/api/tasks/:taskId/complete', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Cancel a running task (stops turtle + marks cancelled)
|
||||||
|
app.post('/api/tasks/:taskId/cancel', (req, res) => {
|
||||||
|
try {
|
||||||
|
const taskId = parseInt(req.params.taskId);
|
||||||
|
taskDispatcher.cancelTask(taskId);
|
||||||
|
res.json({ success: true });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ========== TASK DISPATCHER ENDPOINTS ==========
|
||||||
|
|
||||||
|
// Get dispatcher status
|
||||||
|
app.get('/api/dispatcher/status', (req, res) => {
|
||||||
|
res.json(taskDispatcher.status());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Enable/disable auto-dispatch
|
||||||
|
app.post('/api/dispatcher/toggle', (req, res) => {
|
||||||
|
const { enabled } = req.body;
|
||||||
|
taskDispatcher.enabled = enabled !== undefined ? enabled : !taskDispatcher.enabled;
|
||||||
|
res.json({ enabled: taskDispatcher.enabled });
|
||||||
|
});
|
||||||
|
|
||||||
// ========== MINING AREA ENDPOINTS ==========
|
// ========== MINING AREA ENDPOINTS ==========
|
||||||
|
|
||||||
// Helper to format mining area for API response
|
// Helper to format mining area for API response
|
||||||
@@ -1943,6 +1968,7 @@ app.get('/api/integration/storage-status', async (req, res) => {
|
|||||||
// Graceful shutdown
|
// Graceful shutdown
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
console.log('\n🛑 Shutting down server...');
|
console.log('\n🛑 Shutting down server...');
|
||||||
|
taskDispatcher.stop();
|
||||||
db.closeDatabase();
|
db.closeDatabase();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user