- 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>
39 lines
1021 B
JavaScript
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);
|
|
}
|
|
})();
|