File size: 771 Bytes
c3aa9b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node

/**
 * Clear expired locks from the cache database
 * Use this if a process crashed and left a stale lock
 */

import { CacheService } from '../services/cache-service.js';
import dotenv from 'dotenv';

dotenv.config();

const cacheService = new CacheService(process.env.PAGE_CACHE_PATH || './data/page-cache.db');

console.log('\n🔓 Cleaning up expired locks...\n');

try {
  await cacheService.initialize();
  
  const cleaned = cacheService.cleanupExpiredLocks();
  
  if (cleaned > 0) {
    console.log(`✅ Cleaned up ${cleaned} expired lock(s)\n`);
  } else {
    console.log('✓ No expired locks found - all clear!\n');
  }
  
  cacheService.close();
  
} catch (error) {
  console.error('\n❌ Error:', error.message);
  process.exit(1);
}