Skip to content

Commit

Permalink
fix: wait for deletion to happen beore continuing
Browse files Browse the repository at this point in the history
this fixes our earlier issue with settings being set before the index gets deleted
  • Loading branch information
Haroenv committed Aug 10, 2018
1 parent 1a571ad commit 0734436
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/index.js
Expand Up @@ -98,7 +98,8 @@ async function bootstrap(state) {
log.info('⛷ Bootstrap: starting at doc %s', state.bootstrapLastId);
return loop(state.bootstrapLastId);
} else {
await client.deleteIndex(c.bootstrapIndexName);
const { taskID } = await client.deleteIndex(c.bootstrapIndexName);
await bootstrapIndex.waitTask(taskID);
log.info('⛷ Bootstrap: starting from the first doc');
return (
npm
Expand Down Expand Up @@ -238,26 +239,25 @@ function watch({ seq }) {
})
)
.then(stateManager.get)
// For now we disable this next step because we have a bug where the index got misconfigured after bootstrap/move
// .then(({ bootstrapLastDone }) => {
// const now = Date.now();
// const lastBootstrapped = new Date(bootstrapLastDone);
// // when the process is running longer than a certain time
// // we want to start over and get all info again
// // we do this by exiting and letting Heroku start over
// if (now - lastBootstrapped > c.timeToRedoBootstrap) {
// return stateManager
// .set({
// seq: 0,
// bootstrapDone: false,
// })
// .then(() => {
// process.exit(0); // eslint-disable-line no-process-exit
// });
// }

// return null;
// })
.then(({ bootstrapLastDone }) => {
const now = Date.now();
const lastBootstrapped = new Date(bootstrapLastDone);
// when the process is running longer than a certain time
// we want to start over and get all info again
// we do this by exiting and letting Heroku start over
if (now - lastBootstrapped > c.timeToRedoBootstrap) {
return stateManager
.set({
seq: 0,
bootstrapDone: false,
})
.then(() => {
process.exit(0); // eslint-disable-line no-process-exit
});
}

return null;
})
.then(done)
.catch(done);
}, 1);
Expand Down

0 comments on commit 0734436

Please sign in to comment.