File tree Expand file tree Collapse file tree 5 files changed +16
-10
lines changed
Expand file tree Collapse file tree 5 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ ENV DATA_CACHE_DIR=$DATA_DIR/.sourcebot
8080ENV DB_DATA_DIR=$DATA_CACHE_DIR/db
8181ENV DB_NAME=sourcebot
8282ENV DATABASE_URL="postgresql://postgres@localhost:5432/sourcebot"
83+ ENV REDIS_URL="redis://localhost:6379"
8384ENV SRC_TENANT_ENFORCEMENT_MODE=strict
8485
8586ARG SOURCEBOT_VERSION=unknown
Original file line number Diff line number Diff line change @@ -22,15 +22,18 @@ type JobPayload = {
2222} ;
2323
2424export class ConnectionManager implements IConnectionManager {
25- private queue = new Queue < JobPayload > ( QUEUE_NAME ) ;
2625 private worker : Worker ;
26+ private queue : Queue < JobPayload > ;
2727 private logger = createLogger ( 'ConnectionManager' ) ;
2828
2929 constructor (
3030 private db : PrismaClient ,
3131 private settings : Settings ,
3232 redis : Redis ,
3333 ) {
34+ this . queue = new Queue < JobPayload > ( QUEUE_NAME , {
35+ connection : redis ,
36+ } ) ;
3437 const numCores = os . cpus ( ) . length ;
3538 this . worker = new Worker ( QUEUE_NAME , this . runSyncJob . bind ( this ) , {
3639 connection : redis ,
Original file line number Diff line number Diff line change @@ -35,4 +35,5 @@ export const FALLBACK_GITHUB_TOKEN = getEnv(process.env.FALLBACK_GITHUB_TOKEN);
3535export const FALLBACK_GITLAB_TOKEN = getEnv ( process . env . FALLBACK_GITLAB_TOKEN ) ;
3636export const FALLBACK_GITEA_TOKEN = getEnv ( process . env . FALLBACK_GITEA_TOKEN ) ;
3737
38- export const INDEX_CONCURRENCY_MULTIPLE = getEnv ( process . env . INDEX_CONCURRENCY_MULTIPLE ) ;
38+ export const INDEX_CONCURRENCY_MULTIPLE = getEnv ( process . env . INDEX_CONCURRENCY_MULTIPLE ) ;
39+ export const REDIS_URL = getEnv ( process . env . REDIS_URL , 'redis://localhost:6379' ) ! ;
Original file line number Diff line number Diff line change @@ -5,14 +5,12 @@ import { DEFAULT_SETTINGS } from './constants.js';
55import { Redis } from 'ioredis' ;
66import { ConnectionManager } from './connectionManager.js' ;
77import { RepoManager } from './repoManager.js' ;
8- import { INDEX_CONCURRENCY_MULTIPLE } from './environment.js' ;
8+ import { INDEX_CONCURRENCY_MULTIPLE , REDIS_URL } from './environment.js' ;
99
1010const logger = createLogger ( 'main' ) ;
1111
1212export const main = async ( db : PrismaClient , context : AppContext ) => {
13- const redis = new Redis ( {
14- host : 'localhost' ,
15- port : 6379 ,
13+ const redis = new Redis ( REDIS_URL , {
1614 maxRetriesPerRequest : null
1715 } ) ;
1816 redis . ping ( ) . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ type JobPayload = {
2525}
2626
2727export class RepoManager implements IRepoManager {
28- private queue = new Queue < JobPayload > ( QUEUE_NAME ) ;
2928 private worker : Worker ;
29+ private queue : Queue < JobPayload > ;
3030 private logger = createLogger ( 'RepoManager' ) ;
3131
3232 constructor (
@@ -35,6 +35,9 @@ export class RepoManager implements IRepoManager {
3535 redis : Redis ,
3636 private ctx : AppContext ,
3737 ) {
38+ this . queue = new Queue < JobPayload > ( QUEUE_NAME , {
39+ connection : redis ,
40+ } ) ;
3841 const numCores = os . cpus ( ) . length ;
3942 this . worker = new Worker ( QUEUE_NAME , this . runIndexJob . bind ( this ) , {
4043 connection : redis ,
@@ -46,8 +49,8 @@ export class RepoManager implements IRepoManager {
4649
4750 public async blockingPollLoop ( ) {
4851 while ( true ) {
49- this . fetchAndScheduleRepoIndexing ( ) ;
50- this . garbageCollectRepo ( ) ;
52+ await this . fetchAndScheduleRepoIndexing ( ) ;
53+ await this . garbageCollectRepo ( ) ;
5154
5255 await new Promise ( resolve => setTimeout ( resolve , this . settings . reindexRepoPollingIntervalMs ) ) ;
5356 }
@@ -81,7 +84,7 @@ export class RepoManager implements IRepoManager {
8184 priority : priority
8285 }
8386 } ) ) ) ;
84-
87+
8588 this . logger . info ( `Added ${ orgRepos . length } jobs to queue for org ${ orgId } with priority ${ priority } ` ) ;
8689 }
8790
You can’t perform that action at this time.
0 commit comments