mirror of
https://github.com/Ryujinx/Ryujinx-Ldn-Website.git
synced 2025-08-11 14:21:13 +00:00
Add REDIS_SOCKET env var and prefer it over REDIS_URL
This commit is contained in:
parent
e676e87276
commit
3b7c0b80a1
|
@ -21,11 +21,12 @@
|
||||||
This app can be configured using the following environment variables:
|
This app can be configured using the following environment variables:
|
||||||
|
|
||||||
| Name | Description | Default value | Notes |
|
| Name | Description | Default value | Notes |
|
||||||
| :---------- | ----------------------------------------------------------------------------------------- | :-----------: | ---------------------------------------------------------------------- |
|
| :------------- | ----------------------------------------------------------------------------------------- | :-----------: | ---------------------------------------------------------------------- |
|
||||||
| `NODE_ENV` | This should be set to `production` or `development` depending on the current environment. | `""` | |
|
| `NODE_ENV` | This should be set to `production` or `development` depending on the current environment. | `""` | |
|
||||||
| `HOST` | The address this server should be listening on. | `"127.0.0.1"` | |
|
| `HOST` | The address this server should be listening on. | `"127.0.0.1"` | |
|
||||||
| `PORT` | The port this server should be using. | `3000` | |
|
| `PORT` | The port this server should be using. | `3000` | |
|
||||||
| `REDIS_URL` | The URL of the redis server. | `""` | Format: `redis[s]://[[username][:password]@][host][:port][/db-number]` |
|
| `REDIS_URL` | The URL of the redis server. | `""` | Format: `redis[s]://[[username][:password]@][host][:port][/db-number]` |
|
||||||
|
| `REDIS_SOCKET` | The path to the unix socket of the redis server. | `""` | If this is not empty `REDIS_URL` will be ignored. |
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
|
|
30
src/app.ts
30
src/app.ts
|
@ -1,6 +1,12 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import actuator from "express-actuator";
|
import actuator from "express-actuator";
|
||||||
import { createClient } from "redis";
|
import {
|
||||||
|
RedisClientOptions,
|
||||||
|
RedisFunctions,
|
||||||
|
RedisModules,
|
||||||
|
RedisScripts,
|
||||||
|
createClient,
|
||||||
|
} from "redis";
|
||||||
import winston from "winston";
|
import winston from "winston";
|
||||||
import apiRouter from "./api";
|
import apiRouter from "./api";
|
||||||
import { errorLogger, requestLogger } from "./middleware";
|
import { errorLogger, requestLogger } from "./middleware";
|
||||||
|
@ -20,12 +26,26 @@ export const logger = loggerInstance.child({
|
||||||
source: "Node",
|
source: "Node",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Init Redis client
|
const redisClientOptions: RedisClientOptions<
|
||||||
export const redisClient = createClient({
|
RedisModules,
|
||||||
url: process.env.REDIS_URL,
|
RedisFunctions,
|
||||||
|
RedisScripts
|
||||||
|
> = {
|
||||||
// NOTE: Enable this if we ever start using cluster mode
|
// NOTE: Enable this if we ever start using cluster mode
|
||||||
// readonly: true,
|
// readonly: true,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Prefer unix socket over REDIS_URL
|
||||||
|
if (process.env.REDIS_SOCKET != null && process.env.REDIS_SOCKET.length > 0) {
|
||||||
|
redisClientOptions.socket = {
|
||||||
|
path: process.env.REDIS_SOCKET,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
redisClientOptions.url = process.env.REDIS_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init Redis client
|
||||||
|
export const redisClient = createClient(redisClientOptions);
|
||||||
|
|
||||||
redisClient.on("error", (err: Error) =>
|
redisClient.on("error", (err: Error) =>
|
||||||
loggerInstance.error(err.message, {
|
loggerInstance.error(err.message, {
|
||||||
|
|
Loading…
Reference in a new issue