feat(config): respect REDIS_DB env var for queue and transmit
Allow operators to select a Redis logical database index via the REDIS_DB environment variable. Without this, the BullMQ queue and the @adonisjs/transmit Redis transport both implicitly used db 0, causing key collisions when sharing a Redis instance across multiple services or environments. REDIS_DB is added to the env schema as an optional number; both config/queue.ts and config/transmit.ts fall back to db 0 when unset, preserving existing behavior.
This commit is contained in:
parent
e1c7435fc4
commit
f553a0d57d
|
|
@ -12,6 +12,9 @@ DB_PASSWORD=password
|
||||||
DB_SSL=false
|
DB_SSL=false
|
||||||
REDIS_HOST=localhost
|
REDIS_HOST=localhost
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
# Optional: Redis logical database index (0-15). Defaults to 0 if unset.
|
||||||
|
# Set this when sharing a Redis instance across services to avoid key collisions.
|
||||||
|
# REDIS_DB=0
|
||||||
# Storage path for NOMAD content (ZIM files, maps, etc.)
|
# Storage path for NOMAD content (ZIM files, maps, etc.)
|
||||||
# On Windows dev, use an absolute path like: C:/nomad-storage
|
# On Windows dev, use an absolute path like: C:/nomad-storage
|
||||||
# On Linux production, use: /opt/project-nomad/storage
|
# On Linux production, use: /opt/project-nomad/storage
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ const queueConfig = {
|
||||||
connection: {
|
connection: {
|
||||||
host: env.get('REDIS_HOST'),
|
host: env.get('REDIS_HOST'),
|
||||||
port: env.get('REDIS_PORT') ?? 6379,
|
port: env.get('REDIS_PORT') ?? 6379,
|
||||||
|
db: env.get('REDIS_DB') ?? 0,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ export default defineConfig({
|
||||||
driver: redis({
|
driver: redis({
|
||||||
host: env.get('REDIS_HOST'),
|
host: env.get('REDIS_HOST'),
|
||||||
port: env.get('REDIS_PORT'),
|
port: env.get('REDIS_PORT'),
|
||||||
|
db: env.get('REDIS_DB') ?? 0,
|
||||||
keyPrefix: 'transmit:',
|
keyPrefix: 'transmit:',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ export default await Env.create(new URL('../', import.meta.url), {
|
||||||
*/
|
*/
|
||||||
REDIS_HOST: Env.schema.string({ format: 'host' }),
|
REDIS_HOST: Env.schema.string({ format: 'host' }),
|
||||||
REDIS_PORT: Env.schema.number(),
|
REDIS_PORT: Env.schema.number(),
|
||||||
|
REDIS_DB: Env.schema.number.optional(),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|----------------------------------------------------------
|
|----------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue