mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-25 15:35:12 +00:00
enhance: Redisをioredisに統一してIPv6サポート (#8869)
* Use ioredis, Supports IPv6 host https://github.com/misskey-dev/misskey/issues/8862 * Fix import * order * a * i * fix * flushdb * family * CHANGELOG * redis_version Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
1c2e2c4b06
commit
6f8e3fe366
9 changed files with 26 additions and 32 deletions
|
@ -57,6 +57,7 @@ db:
|
||||||
redis:
|
redis:
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 6379
|
port: 6379
|
||||||
|
#family: 0 # 0=Both, 4=IPv4, 6=IPv6
|
||||||
#pass: example-pass
|
#pass: example-pass
|
||||||
#prefix: example-prefix
|
#prefix: example-prefix
|
||||||
#db: 1
|
#db: 1
|
||||||
|
|
|
@ -18,6 +18,8 @@ You should also include the user name that made the change.
|
||||||
- Improve player detection in URL preview @mei23
|
- Improve player detection in URL preview @mei23
|
||||||
- Add Badge Image to Push Notification #8012 @tamaina
|
- Add Badge Image to Push Notification #8012 @tamaina
|
||||||
- Client: Removing entries from a clip @futchitwo
|
- Client: Removing entries from a clip @futchitwo
|
||||||
|
- Server: Supports IPv6 on Redis transport. @mei23
|
||||||
|
IPv4/IPv6 is used by default. You can tune this behavior via `redis.family`.
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- Server: Fix GenerateVideoThumbnail failed @mei23
|
- Server: Fix GenerateVideoThumbnail failed @mei23
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
"fluent-ffmpeg": "2.1.2",
|
"fluent-ffmpeg": "2.1.2",
|
||||||
"got": "12.1.0",
|
"got": "12.1.0",
|
||||||
"hpagent": "0.1.2",
|
"hpagent": "0.1.2",
|
||||||
|
"ioredis": "4.28.5",
|
||||||
"ip-cidr": "3.0.10",
|
"ip-cidr": "3.0.10",
|
||||||
"is-svg": "4.3.2",
|
"is-svg": "4.3.2",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
|
@ -86,7 +87,6 @@
|
||||||
"random-seed": "0.3.0",
|
"random-seed": "0.3.0",
|
||||||
"ratelimiter": "3.4.1",
|
"ratelimiter": "3.4.1",
|
||||||
"re2": "1.17.4",
|
"re2": "1.17.4",
|
||||||
"redis": "3.1.2",
|
|
||||||
"redis-lock": "0.1.4",
|
"redis-lock": "0.1.4",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"rename": "1.0.4",
|
"rename": "1.0.4",
|
||||||
|
|
|
@ -19,6 +19,7 @@ export type Source = {
|
||||||
redis: {
|
redis: {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
family?: number;
|
||||||
pass: string;
|
pass: string;
|
||||||
db?: number;
|
db?: number;
|
||||||
prefix?: string;
|
prefix?: string;
|
||||||
|
|
|
@ -192,12 +192,13 @@ export const db = new DataSource({
|
||||||
synchronize: process.env.NODE_ENV === 'test',
|
synchronize: process.env.NODE_ENV === 'test',
|
||||||
dropSchema: process.env.NODE_ENV === 'test',
|
dropSchema: process.env.NODE_ENV === 'test',
|
||||||
cache: !config.db.disableCache ? {
|
cache: !config.db.disableCache ? {
|
||||||
type: 'redis',
|
type: 'ioredis',
|
||||||
options: {
|
options: {
|
||||||
host: config.redis.host,
|
host: config.redis.host,
|
||||||
port: config.redis.port,
|
port: config.redis.port,
|
||||||
|
family: config.redis.family == null ? 0 : config.redis.family,
|
||||||
password: config.redis.pass,
|
password: config.redis.pass,
|
||||||
prefix: `${config.redis.prefix}:query:`,
|
keyPrefix: `${config.redis.prefix}:query:`,
|
||||||
db: config.redis.db || 0,
|
db: config.redis.db || 0,
|
||||||
},
|
},
|
||||||
} : false,
|
} : false,
|
||||||
|
@ -226,7 +227,7 @@ export async function initDb(force = false) {
|
||||||
|
|
||||||
export async function resetDb() {
|
export async function resetDb() {
|
||||||
const reset = async () => {
|
const reset = async () => {
|
||||||
await redisClient.FLUSHDB();
|
await redisClient.flushdb();
|
||||||
const tables = await db.query(`SELECT relname AS "table"
|
const tables = await db.query(`SELECT relname AS "table"
|
||||||
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
||||||
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
import * as redis from 'redis';
|
import Redis from 'ioredis';
|
||||||
import config from '@/config/index.js';
|
import config from '@/config/index.js';
|
||||||
|
|
||||||
export function createConnection() {
|
export function createConnection() {
|
||||||
return redis.createClient(
|
return new Redis({
|
||||||
config.redis.port,
|
port: config.redis.port,
|
||||||
config.redis.host,
|
host: config.redis.host,
|
||||||
{
|
family: config.redis.family == null ? 0 : config.redis.family,
|
||||||
password: config.redis.pass,
|
password: config.redis.pass,
|
||||||
prefix: config.redis.prefix,
|
keyPrefix: `${config.redis.prefix}:`,
|
||||||
db: config.redis.db || 0,
|
db: config.redis.db || 0,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const subsdcriber = createConnection();
|
export const subsdcriber = createConnection();
|
||||||
|
|
|
@ -6,6 +6,7 @@ export function initialize<T>(name: string, limitPerSec = -1) {
|
||||||
redis: {
|
redis: {
|
||||||
port: config.redis.port,
|
port: config.redis.port,
|
||||||
host: config.redis.host,
|
host: config.redis.host,
|
||||||
|
family: config.redis.family == null ? 0 : config.redis.family,
|
||||||
password: config.redis.pass,
|
password: config.redis.pass,
|
||||||
db: config.redis.db || 0,
|
db: config.redis.db || 0,
|
||||||
},
|
},
|
||||||
|
|
|
@ -99,12 +99,16 @@ export default define(meta, paramDef, async () => {
|
||||||
const fsStats = await si.fsSize();
|
const fsStats = await si.fsSize();
|
||||||
const netInterface = await si.networkInterfaceDefault();
|
const netInterface = await si.networkInterfaceDefault();
|
||||||
|
|
||||||
|
const redisServerInfo = await redisClient.info('Server');
|
||||||
|
const m = redisServerInfo.match(new RegExp('^redis_version:(.*)', 'm'));
|
||||||
|
const redis_version = m?.[1];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
machine: os.hostname(),
|
machine: os.hostname(),
|
||||||
os: os.platform(),
|
os: os.platform(),
|
||||||
node: process.version,
|
node: process.version,
|
||||||
psql: await db.query('SHOW server_version').then(x => x[0].server_version),
|
psql: await db.query('SHOW server_version').then(x => x[0].server_version),
|
||||||
redis: redisClient.server_info.redis_version,
|
redis: redis_version,
|
||||||
cpu: {
|
cpu: {
|
||||||
model: os.cpus()[0].model,
|
model: os.cpus()[0].model,
|
||||||
cores: os.cpus().length,
|
cores: os.cpus().length,
|
||||||
|
|
|
@ -2227,11 +2227,6 @@ denque@^1.1.0:
|
||||||
resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf"
|
resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf"
|
||||||
integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ==
|
integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ==
|
||||||
|
|
||||||
denque@^1.5.0:
|
|
||||||
version "1.5.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/denque/-/denque-1.5.0.tgz#773de0686ff2d8ec2ff92914316a47b73b1c73de"
|
|
||||||
integrity sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==
|
|
||||||
|
|
||||||
depd@^1.1.2, depd@~1.1.2:
|
depd@^1.1.2, depd@~1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
|
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
|
||||||
|
@ -3581,7 +3576,7 @@ internal-slot@^1.0.3:
|
||||||
has "^1.0.3"
|
has "^1.0.3"
|
||||||
side-channel "^1.0.4"
|
side-channel "^1.0.4"
|
||||||
|
|
||||||
ioredis@^4.28.5:
|
ioredis@4.28.5, ioredis@^4.28.5:
|
||||||
version "4.28.5"
|
version "4.28.5"
|
||||||
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f"
|
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f"
|
||||||
integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A==
|
integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A==
|
||||||
|
@ -5805,7 +5800,7 @@ reconnecting-websocket@^4.4.0:
|
||||||
resolved "https://registry.yarnpkg.com/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz#3b0e5b96ef119e78a03135865b8bb0af1b948783"
|
resolved "https://registry.yarnpkg.com/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz#3b0e5b96ef119e78a03135865b8bb0af1b948783"
|
||||||
integrity sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==
|
integrity sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==
|
||||||
|
|
||||||
redis-commands@1.7.0, redis-commands@^1.7.0:
|
redis-commands@1.7.0:
|
||||||
version "1.7.0"
|
version "1.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.7.0.tgz#15a6fea2d58281e27b1cd1acfb4b293e278c3a89"
|
resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.7.0.tgz#15a6fea2d58281e27b1cd1acfb4b293e278c3a89"
|
||||||
integrity sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==
|
integrity sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==
|
||||||
|
@ -5845,16 +5840,6 @@ redis@*:
|
||||||
"@node-redis/search" "^1.0.2"
|
"@node-redis/search" "^1.0.2"
|
||||||
"@node-redis/time-series" "^1.0.1"
|
"@node-redis/time-series" "^1.0.1"
|
||||||
|
|
||||||
redis@3.1.2:
|
|
||||||
version "3.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/redis/-/redis-3.1.2.tgz#766851117e80653d23e0ed536254677ab647638c"
|
|
||||||
integrity sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==
|
|
||||||
dependencies:
|
|
||||||
denque "^1.5.0"
|
|
||||||
redis-commands "^1.7.0"
|
|
||||||
redis-errors "^1.2.0"
|
|
||||||
redis-parser "^3.0.0"
|
|
||||||
|
|
||||||
reflect-metadata@0.1.13, reflect-metadata@^0.1.13:
|
reflect-metadata@0.1.13, reflect-metadata@^0.1.13:
|
||||||
version "0.1.13"
|
version "0.1.13"
|
||||||
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
|
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
|
||||||
|
|
Loading…
Reference in a new issue