verify_project.mjs 941 B

1234567891011121314151617181920212223242526272829303132333435
  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 redis from '../lib/redis.js'
  6. import { setTimeout } from 'node:timers/promises'
  7. import { loadGlobalBlobs } from '../lib/blob_store/index.js'
  8. const { historyId } = commandLineArgs([{ name: 'historyId', type: String }])
  9. async function gracefulShutdown(code = process.exitCode) {
  10. await knex.destroy()
  11. await client.close()
  12. await redis.disconnect()
  13. await setTimeout(1_000)
  14. process.exit(code)
  15. }
  16. if (!historyId) {
  17. console.error('missing --historyId')
  18. process.exitCode = 1
  19. await gracefulShutdown()
  20. }
  21. await loadGlobalBlobs()
  22. try {
  23. await verifyProjectWithErrorContext(historyId)
  24. console.log('OK')
  25. } catch (error) {
  26. console.error('error verifying', error)
  27. process.exitCode = 1
  28. } finally {
  29. await gracefulShutdown()
  30. }