flush_all.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const ProjectFlusher = require('../app/js/ProjectFlusher')
  2. const minimist = require('minimist')
  3. async function main() {
  4. const argv = minimist(process.argv.slice(2), {
  5. default: {
  6. limit: 100_000,
  7. concurrency: 5,
  8. 'dry-run': false,
  9. 'log-progress': 1_000,
  10. },
  11. boolean: ['dry-run', 'help'],
  12. alias: { h: 'help', n: 'dry-run', j: 'concurrency' },
  13. })
  14. if (argv.help) {
  15. console.log(`
  16. Usage: node scripts/flush_all.js [options]
  17. Options:
  18. --limit Number of projects to flush (default: 100000)
  19. --concurrency, -j Number of concurrent flush operations (default: 5)
  20. --dry-run, -n Perform a dry run without making any changes (default: false)
  21. --log-progress Log progress after flushing every Nth project (default: 1000)
  22. --help, -h Show this help message
  23. `)
  24. process.exit(0)
  25. }
  26. const options = {
  27. limit: argv.limit,
  28. concurrency: argv.concurrency,
  29. dryRun: argv['dry-run'],
  30. logProgress: argv['log-progress'],
  31. }
  32. console.log('Flushing all projects with options:', options)
  33. await ProjectFlusher.promises.flushAllProjects(options)
  34. }
  35. main()
  36. .then(() => {
  37. console.log('Done flushing all projects')
  38. process.exit(0)
  39. })
  40. .catch(error => {
  41. console.error('There was an error flushing all projects', { error })
  42. process.exit(1)
  43. })