diff --git a/src/index.js b/src/index.js index 519fe7782..a70f1baa3 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,8 @@ import * as watch from './watch.js'; log.info('🗿 npm ↔️ Algolia replication starts ⛷ 🐌 🛰'); +const KILL_PROCESS_EVERY_MS = 12 * 60 * 60 * 1000; // every 12 hours + /** * Main process * - Bootstrap: will index the whole list of packages (if needed) @@ -18,6 +20,16 @@ log.info('🗿 npm ↔️ Algolia replication starts ⛷ 🐌 🛰'); */ async function main() { const start = Date.now(); + + // We schedule to kill the process: + // - reset cache + // - maybe retrigger bootstrap + setTimeout(() => { + log.info('👋 Scheduled process cleaning'); + // eslint-disable-next-line no-process-exit + process.exit(0); + }, KILL_PROCESS_EVERY_MS); + // first we make sure the bootstrap index has the correct settings log.info('💪 Setting up Algolia'); const {