Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

fix: parse redis url to get hostname and port (#5502)

M. Palanikannan1cd725985290
diff --git a/live/.env.example b/live/.env.example
index de5e5c1f0c..b7c27e825f 100644
--- a/live/.env.example
+++ b/live/.env.example
@@ -1,3 +1,6 @@
API_BASE_URL="http://api:8000"
-REDIS_HOST="localhost"
-REDIS_PORT="6379"
\ No newline at end of file
+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
diff --git a/live/src/core/config/redis-config.ts b/live/src/core/config/redis-config.ts
new file mode 100644
index 0000000000..ff52fea414
--- /dev/null
+++ b/live/src/core/config/redis-config.ts
@@ -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 "";
+}
diff --git a/live/src/server.ts b/live/src/server.ts
index b1c53b2252..6610042362 100644
--- a/live/src/server.ts
+++ b/live/src/server.ts
@@ -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 ({