Files
cannaiq/backend/archive/fix-stuck-job.js
Kelly d91c55a344 feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes)
- Add users management route
- Add frontend landing page and stale process monitor UI on /scraper-tools
- Move old development scripts to backend/archive/
- Update frontend build with new features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 04:07:31 -07:00

39 lines
1021 B
JavaScript

const { Pool } = require('pg');
const pool = new Pool({
connectionString: process.env.DATABASE_URL || 'postgresql://kelly:kelly@localhost:5432/hub'
});
(async () => {
try {
// Check for stuck jobs
const result = await pool.query(`
SELECT id, status, total_proxies, tested_proxies, started_at
FROM proxy_test_jobs
WHERE status IN ('pending', 'running')
ORDER BY created_at DESC
`);
console.log('Found stuck jobs:', result.rows);
// Mark them as cancelled
if (result.rows.length > 0) {
await pool.query(`
UPDATE proxy_test_jobs
SET status = 'cancelled',
completed_at = CURRENT_TIMESTAMP,
updated_at = CURRENT_TIMESTAMP
WHERE status IN ('pending', 'running')
`);
console.log('✅ Cleaned up', result.rows.length, 'stuck jobs');
} else {
console.log('No stuck jobs found');
}
process.exit(0);
} catch (error) {
console.error('❌ Error:', error);
process.exit(1);
}
})();