Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: kill process regurlarly, for cache and bootstrap #412

Merged
merged 3 commits into from
Aug 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@ 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)
* - Watch : will process update in real time
*/
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 {
Expand Down