Fixing issues with Redis/Bull and the integration with new redis module.
This commit is contained in:
parent
b01da0aad5
commit
1cf778845a
|
@ -105,8 +105,6 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
image: redis
|
image: redis
|
||||||
command: redis-server --requirepass ${REDIS_PASSWORD}
|
command: redis-server --requirepass ${REDIS_PASSWORD}
|
||||||
ports:
|
|
||||||
- "${REDIS_PORT}:6379"
|
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,6 @@ static_resources:
|
||||||
cluster: couchdb-service
|
cluster: couchdb-service
|
||||||
prefix_rewrite: "/"
|
prefix_rewrite: "/"
|
||||||
|
|
||||||
- match: { prefix: "/cache/" }
|
|
||||||
route:
|
|
||||||
cluster: redis-service
|
|
||||||
prefix_rewrite: "/"
|
|
||||||
|
|
||||||
- match: { prefix: "/api/admin/" }
|
- match: { prefix: "/api/admin/" }
|
||||||
route:
|
route:
|
||||||
cluster: worker-dev
|
cluster: worker-dev
|
||||||
|
@ -89,20 +84,6 @@ static_resources:
|
||||||
address: couchdb-service
|
address: couchdb-service
|
||||||
port_value: 5984
|
port_value: 5984
|
||||||
|
|
||||||
- name: redis-service
|
|
||||||
connect_timeout: 0.25s
|
|
||||||
type: strict_dns
|
|
||||||
lb_policy: round_robin
|
|
||||||
load_assignment:
|
|
||||||
cluster_name: redis-service
|
|
||||||
endpoints:
|
|
||||||
- lb_endpoints:
|
|
||||||
- endpoint:
|
|
||||||
address:
|
|
||||||
socket_address:
|
|
||||||
address: redis-service
|
|
||||||
port_value: 6379
|
|
||||||
|
|
||||||
- name: server-dev
|
- name: server-dev
|
||||||
connect_timeout: 0.25s
|
connect_timeout: 0.25s
|
||||||
type: strict_dns
|
type: strict_dns
|
||||||
|
|
|
@ -41,11 +41,6 @@ static_resources:
|
||||||
cluster: worker-service
|
cluster: worker-service
|
||||||
prefix_rewrite: "/"
|
prefix_rewrite: "/"
|
||||||
|
|
||||||
- match: { prefix: "/cache/" }
|
|
||||||
route:
|
|
||||||
cluster: redis-service
|
|
||||||
prefix_rewrite: "/"
|
|
||||||
|
|
||||||
- match: { prefix: "/db/" }
|
- match: { prefix: "/db/" }
|
||||||
route:
|
route:
|
||||||
cluster: couchdb-service
|
cluster: couchdb-service
|
||||||
|
@ -117,18 +112,3 @@ static_resources:
|
||||||
address: couchdb-service
|
address: couchdb-service
|
||||||
port_value: 5984
|
port_value: 5984
|
||||||
|
|
||||||
- name: redis-service
|
|
||||||
connect_timeout: 0.25s
|
|
||||||
type: strict_dns
|
|
||||||
lb_policy: round_robin
|
|
||||||
load_assignment:
|
|
||||||
cluster_name: redis-service
|
|
||||||
endpoints:
|
|
||||||
- lb_endpoints:
|
|
||||||
- endpoint:
|
|
||||||
address:
|
|
||||||
socket_address:
|
|
||||||
address: redis-service
|
|
||||||
port_value: 6379
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,10 @@ module.exports = {
|
||||||
setDB(pouch)
|
setDB(pouch)
|
||||||
},
|
},
|
||||||
db: require("./db/utils"),
|
db: require("./db/utils"),
|
||||||
|
redis: {
|
||||||
|
client: require("./redis"),
|
||||||
|
utils: require("./redis/utils"),
|
||||||
|
},
|
||||||
utils: {
|
utils: {
|
||||||
...require("./utils"),
|
...require("./utils"),
|
||||||
...require("./hashing"),
|
...require("./hashing"),
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
const Redis = require("ioredis")
|
const Redis = require("ioredis")
|
||||||
const env = require("../environment")
|
const { addDbPrefix, removeDbPrefix, getRedisOptions } = require("./utils")
|
||||||
const { addDbPrefix, removeDbPrefix } = require("./utils")
|
|
||||||
|
|
||||||
const CONNECT_TIMEOUT_MS = 10000
|
|
||||||
const SLOT_REFRESH_MS = 2000
|
|
||||||
const CLUSTERED = false
|
const CLUSTERED = false
|
||||||
|
|
||||||
let CLIENT
|
let CLIENT
|
||||||
|
@ -15,21 +12,10 @@ let CLIENT
|
||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const [host, port] = env.REDIS_URL.split(":")
|
const { opts, host, port } = getRedisOptions(CLUSTERED)
|
||||||
const opts = {
|
|
||||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
|
||||||
}
|
|
||||||
if (CLUSTERED) {
|
if (CLUSTERED) {
|
||||||
opts.redisOptions = {}
|
CLIENT = new Redis.Cluster([{ host, port }], opts)
|
||||||
opts.redisOptions.tls = {}
|
|
||||||
opts.redisOptions.password = env.REDIS_PASSWORD
|
|
||||||
opts.slotsRefreshTimeout = SLOT_REFRESH_MS
|
|
||||||
opts.dnsLookup = (address, callback) => callback(null, address)
|
|
||||||
CLIENT = new Redis.Cluster([{ port, host }])
|
|
||||||
} else {
|
} else {
|
||||||
opts.password = env.REDIS_PASSWORD
|
|
||||||
opts.port = port
|
|
||||||
opts.host = host
|
|
||||||
CLIENT = new Redis(opts)
|
CLIENT = new Redis(opts)
|
||||||
}
|
}
|
||||||
CLIENT.on("end", err => {
|
CLIENT.on("end", err => {
|
||||||
|
|
|
@ -1,9 +1,32 @@
|
||||||
|
const env = require("../environment")
|
||||||
|
|
||||||
|
const SLOT_REFRESH_MS = 2000
|
||||||
|
const CONNECT_TIMEOUT_MS = 10000
|
||||||
const SEPARATOR = "-"
|
const SEPARATOR = "-"
|
||||||
|
|
||||||
exports.Databases = {
|
exports.Databases = {
|
||||||
PW_RESETS: "pwReset",
|
PW_RESETS: "pwReset",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.getRedisOptions = (clustered = false) => {
|
||||||
|
const [host, port] = env.REDIS_URL.split(":")
|
||||||
|
const opts = {
|
||||||
|
connectTimeout: CONNECT_TIMEOUT_MS,
|
||||||
|
}
|
||||||
|
if (clustered) {
|
||||||
|
opts.redisOptions = {}
|
||||||
|
opts.redisOptions.tls = {}
|
||||||
|
opts.redisOptions.password = env.REDIS_PASSWORD
|
||||||
|
opts.slotsRefreshTimeout = SLOT_REFRESH_MS
|
||||||
|
opts.dnsLookup = (address, callback) => callback(null, address)
|
||||||
|
} else {
|
||||||
|
opts.host = host
|
||||||
|
opts.port = port
|
||||||
|
opts.password = env.REDIS_PASSWORD
|
||||||
|
}
|
||||||
|
return { opts, host, port }
|
||||||
|
}
|
||||||
|
|
||||||
exports.addDbPrefix = (db, key) => {
|
exports.addDbPrefix = (db, key) => {
|
||||||
return `${db}${SEPARATOR}${key}`
|
return `${db}${SEPARATOR}${key}`
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,10 @@ async function init() {
|
||||||
PORT: 4001,
|
PORT: 4001,
|
||||||
MINIO_URL: "http://localhost:10000/",
|
MINIO_URL: "http://localhost:10000/",
|
||||||
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
||||||
REDIS_URL: "http://localhost:10000/cache/",
|
REDIS_URL: "localhost:6379",
|
||||||
WORKER_URL: "http://localhost:4002",
|
WORKER_URL: "http://localhost:4002",
|
||||||
JWT_SECRET: "testsecret",
|
JWT_SECRET: "testsecret",
|
||||||
|
REDIS_PASSWORD: "budibase",
|
||||||
MINIO_ACCESS_KEY: "budibase",
|
MINIO_ACCESS_KEY: "budibase",
|
||||||
MINIO_SECRET_KEY: "budibase",
|
MINIO_SECRET_KEY: "budibase",
|
||||||
COUCH_DB_PASSWORD: "budibase",
|
COUCH_DB_PASSWORD: "budibase",
|
||||||
|
|
|
@ -4,8 +4,10 @@ const Queue = require("bull")
|
||||||
const { setQueues, BullAdapter } = require("bull-board")
|
const { setQueues, BullAdapter } = require("bull-board")
|
||||||
const { getAutomationParams } = require("../db/utils")
|
const { getAutomationParams } = require("../db/utils")
|
||||||
const { coerce } = require("../utilities/rowProcessor")
|
const { coerce } = require("../utilities/rowProcessor")
|
||||||
|
const { utils } = require("@budibase/auth").redis
|
||||||
|
|
||||||
let automationQueue = new Queue("automationQueue")
|
const { opts } = utils.getRedisOptions()
|
||||||
|
let automationQueue = new Queue("automationQueue", { redis: opts })
|
||||||
|
|
||||||
// Set up queues for bull board admin
|
// Set up queues for bull board admin
|
||||||
setQueues([new BullAdapter(automationQueue)])
|
setQueues([new BullAdapter(automationQueue)])
|
||||||
|
|
|
@ -12,6 +12,8 @@ async function init() {
|
||||||
MINIO_SECRET_KEY: "budibase",
|
MINIO_SECRET_KEY: "budibase",
|
||||||
COUCH_DB_USER: "budibase",
|
COUCH_DB_USER: "budibase",
|
||||||
COUCH_DB_PASSWORD: "budibase",
|
COUCH_DB_PASSWORD: "budibase",
|
||||||
|
REDIS_URL: "localhost:6379",
|
||||||
|
REDIS_PASSWORD: "budibase",
|
||||||
MINIO_URL: "http://localhost:10000/",
|
MINIO_URL: "http://localhost:10000/",
|
||||||
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue