mirror of
https://github.com/makeplane/plane.git
synced 2026-04-30 13:09:36 -05:00
fix: parse redis url to get hostname and port (#5502)
* fix: parse redis url to get hostname and port * fix: redis url accepted for connection * chore: add redis url to example env * fix: let users add redis port and host incase redis url is not present * chore: create url from host and port variables * fix: return empty string incase of no config
This commit is contained in:
+5
-2
@@ -1,3 +1,6 @@
|
||||
API_BASE_URL="http://api:8000"
|
||||
REDIS_HOST="localhost"
|
||||
REDIS_PORT="6379"
|
||||
REDIS_URL="redis://localhost:6379"
|
||||
|
||||
# If you prefer not to provide a Redis URL, you can set the REDIS_HOST and REDIS_PORT environment variables instead.
|
||||
REDIS_PORT=6379
|
||||
REDIS_HOST=localhost
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
type RedisConfig = string | { host: string; port: number } | null;
|
||||
|
||||
export function getRedisConfig(): RedisConfig {
|
||||
const redisUrl = process.env.REDIS_URL?.trim();
|
||||
const redisHost = process.env.REDIS_HOST?.trim();
|
||||
const redisPort = process.env.REDIS_PORT?.trim();
|
||||
|
||||
if (redisUrl) {
|
||||
return redisUrl;
|
||||
}
|
||||
|
||||
if (redisHost && redisPort && !Number.isNaN(Number(redisPort))) {
|
||||
return `redis://${redisHost}:${redisPort}`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
+4
-4
@@ -11,6 +11,8 @@ import {
|
||||
fetchPageDescriptionBinary,
|
||||
updatePageDescription,
|
||||
} from "@/core/lib/page.js";
|
||||
// config
|
||||
import { getRedisConfig } from "./core/config/redis-config.js";
|
||||
// types
|
||||
import { TDocumentTypes } from "@/core/types/common.js";
|
||||
// plane live lib
|
||||
@@ -46,10 +48,8 @@ const server = Server.configure({
|
||||
}
|
||||
},
|
||||
extensions: [
|
||||
new Redis({
|
||||
host: process.env.REDIS_HOST || "localhost",
|
||||
port: Number(process.env.REDIS_PORT || 6379),
|
||||
}),
|
||||
// @ts-expect-error - redis from hocuspocus is not typed properly
|
||||
new Redis(getRedisConfig()),
|
||||
new Logger(),
|
||||
new Database({
|
||||
fetch: async ({
|
||||
|
||||
Reference in New Issue
Block a user