mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Better handling of cases when redis isnt configured
This commit is contained in:
parent
d29c26d93b
commit
b4ce07efd3
1 changed files with 24 additions and 17 deletions
|
|
@ -1,31 +1,38 @@
|
|||
import { env } from './env'
|
||||
|
||||
import { Queue } from 'bullmq'
|
||||
import { Queue, RedisOptions } from 'bullmq'
|
||||
import Redis from 'ioredis'
|
||||
|
||||
const redisOptions = () => {
|
||||
if (env.redis.url?.startsWith('rediss://') && env.redis.cert) {
|
||||
const createRSSRefreshFeedQueue = (): Queue | undefined => {
|
||||
if (!env.redis.url) {
|
||||
return undefined
|
||||
}
|
||||
const redisOptions = (): RedisOptions => {
|
||||
if (env.redis.url?.startsWith('rediss://') && env.redis.cert) {
|
||||
return {
|
||||
tls: {
|
||||
cert: env.redis.cert?.replace(/\\n/g, '\n'),
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
maxRetriesPerRequest: null,
|
||||
}
|
||||
}
|
||||
return {
|
||||
tls: {
|
||||
cert: env.redis.cert?.replace(/\\n/g, '\n'),
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
maxRetriesPerRequest: null,
|
||||
}
|
||||
}
|
||||
return {
|
||||
maxRetriesPerRequest: null,
|
||||
}
|
||||
|
||||
const connection = new Redis(env.redis.url ?? '', redisOptions())
|
||||
return new Queue('rssRefreshFeed', { connection })
|
||||
}
|
||||
|
||||
const connection = new Redis(env.redis.url ?? '', redisOptions())
|
||||
|
||||
export const rssRefreshFeedJobQueue = new Queue('rssRefreshFeed', {
|
||||
connection,
|
||||
})
|
||||
|
||||
export const addRefreshFeedJob = async (jobid: string, payload: any) => {
|
||||
return rssRefreshFeedJobQueue.add('rssRefreshFeed', payload, {
|
||||
const rssRefreshFeedJobQueue = createRSSRefreshFeedQueue()
|
||||
|
||||
if (!rssRefreshFeedJobQueue) {
|
||||
return false
|
||||
}
|
||||
return rssRefreshFeedJobQueue?.add('rssRefreshFeed', payload, {
|
||||
jobId: jobid,
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue