- 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>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
const { Pool } = require('pg');
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL || 'postgresql://kelly:kelly@localhost:5432/hub'
|
|
});
|
|
|
|
(async () => {
|
|
try {
|
|
// Check for existing running jobs first
|
|
const existingJob = await pool.query(`
|
|
SELECT id, status FROM proxy_test_jobs
|
|
WHERE status IN ('pending', 'running')
|
|
ORDER BY created_at DESC
|
|
LIMIT 1
|
|
`);
|
|
|
|
if (existingJob.rows.length > 0) {
|
|
console.log(`❌ A proxy test job is already running (ID: ${existingJob.rows[0].id}, Status: ${existingJob.rows[0].status})`);
|
|
console.log('Please cancel it first or wait for it to complete.');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Get total proxy count
|
|
const result = await pool.query(`SELECT COUNT(*) as count FROM proxies`);
|
|
const totalProxies = parseInt(result.rows[0].count);
|
|
|
|
console.log(`📊 Found ${totalProxies} proxies to test`);
|
|
|
|
// Create new job
|
|
const jobResult = await pool.query(`
|
|
INSERT INTO proxy_test_jobs (status, total_proxies)
|
|
VALUES ('pending', $1)
|
|
RETURNING id
|
|
`, [totalProxies]);
|
|
|
|
const jobId = jobResult.rows[0].id;
|
|
|
|
console.log(`✅ Proxy test job created with ID: ${jobId}`);
|
|
console.log(`🚀 Job will start automatically in the background`);
|
|
console.log(`📈 Monitor progress on the Proxies page in the UI`);
|
|
console.log(`\nJob details:`);
|
|
console.log(` - Total proxies: ${totalProxies}`);
|
|
console.log(` - Status: pending → will start momentarily`);
|
|
console.log(` - Expected duration: ~${Math.ceil(totalProxies * 3 / 60)} minutes (without bot detection delays)`);
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Error:', error.message);
|
|
process.exit(1);
|
|
}
|
|
})();
|