File tree 5 files changed +16
-10
lines changed
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
80
80
ENV DB_DATA_DIR=$DATA_CACHE_DIR/db
81
81
ENV DB_NAME=sourcebot
82
82
ENV DATABASE_URL="postgresql://postgres@localhost:5432/sourcebot"
83
+ ENV REDIS_URL="redis://localhost:6379"
83
84
ENV SRC_TENANT_ENFORCEMENT_MODE=strict
84
85
85
86
ARG SOURCEBOT_VERSION=unknown
Original file line number Diff line number Diff line change @@ -22,15 +22,18 @@ type JobPayload = {
22
22
} ;
23
23
24
24
export class ConnectionManager implements IConnectionManager {
25
- private queue = new Queue < JobPayload > ( QUEUE_NAME ) ;
26
25
private worker : Worker ;
26
+ private queue : Queue < JobPayload > ;
27
27
private logger = createLogger ( 'ConnectionManager' ) ;
28
28
29
29
constructor (
30
30
private db : PrismaClient ,
31
31
private settings : Settings ,
32
32
redis : Redis ,
33
33
) {
34
+ this . queue = new Queue < JobPayload > ( QUEUE_NAME , {
35
+ connection : redis ,
36
+ } ) ;
34
37
const numCores = os . cpus ( ) . length ;
35
38
this . worker = new Worker ( QUEUE_NAME , this . runSyncJob . bind ( this ) , {
36
39
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);
35
35
export const FALLBACK_GITLAB_TOKEN = getEnv ( process . env . FALLBACK_GITLAB_TOKEN ) ;
36
36
export const FALLBACK_GITEA_TOKEN = getEnv ( process . env . FALLBACK_GITEA_TOKEN ) ;
37
37
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';
5
5
import { Redis } from 'ioredis' ;
6
6
import { ConnectionManager } from './connectionManager.js' ;
7
7
import { RepoManager } from './repoManager.js' ;
8
- import { INDEX_CONCURRENCY_MULTIPLE } from './environment.js' ;
8
+ import { INDEX_CONCURRENCY_MULTIPLE , REDIS_URL } from './environment.js' ;
9
9
10
10
const logger = createLogger ( 'main' ) ;
11
11
12
12
export 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 , {
16
14
maxRetriesPerRequest : null
17
15
} ) ;
18
16
redis . ping ( ) . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ type JobPayload = {
25
25
}
26
26
27
27
export class RepoManager implements IRepoManager {
28
- private queue = new Queue < JobPayload > ( QUEUE_NAME ) ;
29
28
private worker : Worker ;
29
+ private queue : Queue < JobPayload > ;
30
30
private logger = createLogger ( 'RepoManager' ) ;
31
31
32
32
constructor (
@@ -35,6 +35,9 @@ export class RepoManager implements IRepoManager {
35
35
redis : Redis ,
36
36
private ctx : AppContext ,
37
37
) {
38
+ this . queue = new Queue < JobPayload > ( QUEUE_NAME , {
39
+ connection : redis ,
40
+ } ) ;
38
41
const numCores = os . cpus ( ) . length ;
39
42
this . worker = new Worker ( QUEUE_NAME , this . runIndexJob . bind ( this ) , {
40
43
connection : redis ,
@@ -46,8 +49,8 @@ export class RepoManager implements IRepoManager {
46
49
47
50
public async blockingPollLoop ( ) {
48
51
while ( true ) {
49
- this . fetchAndScheduleRepoIndexing ( ) ;
50
- this . garbageCollectRepo ( ) ;
52
+ await this . fetchAndScheduleRepoIndexing ( ) ;
53
+ await this . garbageCollectRepo ( ) ;
51
54
52
55
await new Promise ( resolve => setTimeout ( resolve , this . settings . reindexRepoPollingIntervalMs ) ) ;
53
56
}
@@ -81,7 +84,7 @@ export class RepoManager implements IRepoManager {
81
84
priority : priority
82
85
}
83
86
} ) ) ) ;
84
-
87
+
85
88
this . logger . info ( `Added ${ orgRepos . length } jobs to queue for org ${ orgId } with priority ${ priority } ` ) ;
86
89
}
87
90
You can’t perform that action at this time.
0 commit comments