-
-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: redis max number of clients reached
due to initializing probot instance for every job run fixed by sharing probot instance
- Loading branch information
Showing
4 changed files
with
42 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { appConfig } from "@/src/configs/app-config.ts"; | ||
import { Redis } from "ioredis"; | ||
|
||
export const getRedisClient = () => { | ||
export const getRedisClient = (name?: string) => { | ||
const redisClient = new Redis(appConfig.redisConfig!, { | ||
maxRetriesPerRequest: null, | ||
name, | ||
}); | ||
return redisClient; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import type { Job } from "bullmq"; | ||
import { createProbot } from "probot"; | ||
import { SchedulerJobData } from "@wei/probot-scheduler"; | ||
import type { SchedulerJobData } from "@wei/probot-scheduler"; | ||
import type { Probot } from "probot"; | ||
import logger from "@/src/utils/logger.ts"; | ||
import { getPullConfig } from "@/src/utils/get-pull-config.ts"; | ||
import { Pull } from "@/src/processor/pull.ts"; | ||
|
||
export default async function RepoJobProcessor(job: Job<SchedulerJobData>) { | ||
const log = logger.child({ | ||
jobId: job.id, | ||
jobData: job.data, | ||
}); | ||
export function getRepoProcessor(probot: Probot) { | ||
return async function RepoJobProcessor(job: Job<SchedulerJobData>) { | ||
const log = logger.child({ | ||
jobId: job.id, | ||
jobData: job.data, | ||
}); | ||
|
||
log.info("🏃 Processing repo job"); | ||
log.info("🏃 Processing repo job"); | ||
|
||
const { installation_id, owner, repo } = job.data; | ||
const { installation_id, owner, repo } = job.data; | ||
|
||
try { | ||
// Get Octokit | ||
const probot = createProbot({ overrides: { log } }); | ||
const octokit = await probot.auth(installation_id); | ||
try { | ||
const octokit = await probot.auth(installation_id); | ||
|
||
const config = await getPullConfig(octokit, log, job.data); | ||
if (!config) { | ||
log.info(`⚠️ No config found, skipping`); | ||
return; | ||
} | ||
const config = await getPullConfig(octokit, log, job.data); | ||
if (!config) { | ||
log.info(`⚠️ No config found, skipping`); | ||
return; | ||
} | ||
|
||
const pull = new Pull(octokit, { owner, repo, logger: log }, config); | ||
await pull.routineCheck(); | ||
const pull = new Pull(octokit, { owner, repo, logger: log }, config); | ||
await pull.routineCheck(); | ||
|
||
log.info(`✅ Repo job ${job.id} processed successfully`); | ||
} catch (error) { | ||
log.error(error, "❌ Repo job failed"); | ||
} | ||
log.info(`✅ Repo job ${job.id} processed successfully`); | ||
} catch (error) { | ||
log.error(error, "❌ Repo job failed"); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters