Skip to content

Commit 9c778b2

Browse files
bodinsamuelHaroenv
andauthored
fix: kill process regurlarly, for cache and bootstrap (#412)
Co-Authored-By: Haroen Viaene <hello@haroen.me>
1 parent b785e8f commit 9c778b2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@ import * as watch from './watch.js';
1111

1212
log.info('🗿 npm ↔️ Algolia replication starts ⛷ 🐌 🛰');
1313

14+
const KILL_PROCESS_EVERY_MS = 12 * 60 * 60 * 1000; // every 12 hours
15+
1416
/**
1517
* Main process
1618
* - Bootstrap: will index the whole list of packages (if needed)
1719
* - Watch : will process update in real time
1820
*/
1921
async function main() {
2022
const start = Date.now();
23+
24+
// We schedule to kill the process:
25+
// - reset cache
26+
// - maybe retrigger bootstrap
27+
setTimeout(() => {
28+
log.info('👋 Scheduled process cleaning');
29+
// eslint-disable-next-line no-process-exit
30+
process.exit(0);
31+
}, KILL_PROCESS_EVERY_MS);
32+
2133
// first we make sure the bootstrap index has the correct settings
2234
log.info('💪 Setting up Algolia');
2335
const {

0 commit comments

Comments
 (0)