Skip to content

Commit

Permalink
graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 8, 2023
1 parent dc6b7f6 commit aa7a337
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/pds/src/migrate-script/migrate-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@ export const runScript = async () => {
let pdsCounter = 0
let completed = 0
let failed = 0

console.log('migrating: ', todo.length)

const migrateQueue = new PQueue({ concurrency: 40 })
process.on('SIGINT', async () => {
migrateQueue.clear()
console.log(`waiting on ${migrateQueue.pending} to finish`)
await migrateQueue.onIdle()
process.exit(0)
})

for (const status of todo) {
if (!status.pdsId) {
status.pdsId = pdsInfos[pdsCounter % pdsInfos.length].id
Expand Down

0 comments on commit aa7a337

Please sign in to comment.