mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-29 15:14:56 +02:00
Redis
This commit is contained in:
parent
7691bdd181
commit
f9798a8d86
2 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import Redis, { RedisOptions } from "ioredis";
|
import Redis, { RedisOptions } from "ioredis";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
|
||||||
class RedisManager {
|
class RedisManager {
|
||||||
public client: Redis | null = null;
|
public client: Redis | null = null;
|
||||||
|
@ -16,7 +17,11 @@ class RedisManager {
|
||||||
> = new Map();
|
> = new Map();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.isEnabled = config.getRawConfig().flags?.enable_redis || false;
|
if (build == "oss") {
|
||||||
|
this.isEnabled = false;
|
||||||
|
} else {
|
||||||
|
this.isEnabled = config.getRawConfig().flags?.enable_redis || false;
|
||||||
|
}
|
||||||
if (this.isEnabled) {
|
if (this.isEnabled) {
|
||||||
this.initializeClients();
|
this.initializeClients();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { z } from "zod";
|
||||||
import stoi from "./stoi";
|
import stoi from "./stoi";
|
||||||
import { passwordSchema } from "@server/auth/passwordSchema";
|
import { passwordSchema } from "@server/auth/passwordSchema";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
|
||||||
const portSchema = z.number().positive().gt(0).lte(65535);
|
const portSchema = z.number().positive().gt(0).lte(65535);
|
||||||
|
|
||||||
|
@ -259,7 +260,21 @@ export const configSchema = z
|
||||||
{
|
{
|
||||||
message: "At least one domain must be defined"
|
message: "At least one domain must be defined"
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
.refine(
|
||||||
|
(data) => {
|
||||||
|
if (build == "oss" && data.redis) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (build == "oss" && data.flags?.enable_redis) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: "Redis"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export function readConfigFile() {
|
export function readConfigFile() {
|
||||||
const loadConfig = (configPath: string) => {
|
const loadConfig = (configPath: string) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue