verify_project.mjs 878 B

123456789101112131415161718192021222324252627282930313233
  1. import commandLineArgs from 'command-line-args'
  2. import { verifyProjectWithErrorContext } from '../lib/backupVerifier.mjs'
  3. import knex from '../lib/knex.js'
  4. import { client } from '../lib/mongodb.js'
  5. import { setTimeout } from 'node:timers/promises'
  6. import { loadGlobalBlobs } from '../lib/blob_store/index.js'
  7. const { historyId } = commandLineArgs([{ name: 'historyId', type: String }])
  8. async function gracefulShutdown(code = process.exitCode) {
  9. await knex.destroy()
  10. await client.close()
  11. await setTimeout(1_000)
  12. process.exit(code)
  13. }
  14. if (!historyId) {
  15. console.error('missing --historyId')
  16. process.exitCode = 1
  17. await gracefulShutdown()
  18. }
  19. await loadGlobalBlobs()
  20. try {
  21. await verifyProjectWithErrorContext(historyId)
  22. console.log('OK')
  23. } catch (error) {
  24. console.error('error verifying', error)
  25. process.exitCode = 1
  26. } finally {
  27. await gracefulShutdown()
  28. }