Skip to content

Set resync and reindex period as environment variable #197

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions packages/backend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Settings } from "./types.js";
export const DEFAULT_SETTINGS: Settings = {
maxFileSize: 2 * 1024 * 1024, // 2MB in bytes
maxTrigramCount: 20000,
autoDeleteStaleRepos: true,
reindexInterval: 1000 * 60 * 60, // 1 hour in milliseconds
resyncInterval: 1000 * 60 * 60 * 24, // 1 day in milliseconds
}
autoDeleteStaleRepos: true
}

9 changes: 9 additions & 0 deletions packages/backend/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export const getEnvBoolean = (env: string | undefined, defaultValue: boolean) =>
return env === 'true' || env === '1';
}

export const getEnvNumber = (env: number | undefined, defaultValue: number ) => {
if (!env) {
return defaultValue;
}
return env;
}

dotenv.config({
path: './.env',
});
Expand All @@ -21,3 +28,5 @@ export const SOURCEBOT_INSTALL_ID = getEnv(process.env.SOURCEBOT_INSTALL_ID, 'un
export const SOURCEBOT_VERSION = getEnv(process.env.SOURCEBOT_VERSION, 'unknown')!;
export const POSTHOG_PAPIK = getEnv(process.env.POSTHOG_PAPIK);
export const POSTHOG_HOST = getEnv(process.env.POSTHOG_HOST);
export const REINDEX_INTERVAL_MS = getEnvNumber(Number(process.env.REINDEX_INTERVAL_MS), 1000*60*60 )!;
export const RESYNC_CONFIG_INTERVAL_MS = getEnvNumber(Number(process.env.RESYNC_CONFIG_INTERVAL_MS), 1000*60*60*24 )!;
1 change: 1 addition & 0 deletions packages/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createLogger } from "./logger.js";
import { createRepository, Database, loadDB, updateRepository, updateSettings } from './db.js';
import { arraysEqualShallow, isRemotePath, measure } from "./utils.js";
import { DEFAULT_SETTINGS } from "./constants.js";
import { REINDEX_INTERVAL_MS, RESYNC_CONFIG_INTERVAL_MS } from './environment.js';
import stripJsonComments from 'strip-json-comments';
import { indexGitRepository, indexLocalRepository } from "./zoekt.js";
import { getLocalRepoFromConfig, initLocalRepoFileWatchers } from "./local.js";
Expand Down