mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(core): Stop explicit redis client disconnect on shutdown (#10551)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run
This commit is contained in:
parent
fcc46b693f
commit
f71281221e
|
@ -2,12 +2,10 @@ import { Service } from 'typedi';
|
||||||
import { Logger } from '@/logger';
|
import { Logger } from '@/logger';
|
||||||
import ioRedis from 'ioredis';
|
import ioRedis from 'ioredis';
|
||||||
import type { Cluster, RedisOptions } from 'ioredis';
|
import type { Cluster, RedisOptions } from 'ioredis';
|
||||||
import type { RedisClientType } from './redis.types';
|
|
||||||
|
|
||||||
import { OnShutdown } from '@/decorators/on-shutdown';
|
|
||||||
import { LOWEST_SHUTDOWN_PRIORITY } from '@/constants';
|
|
||||||
import { GlobalConfig } from '@n8n/config';
|
import { GlobalConfig } from '@n8n/config';
|
||||||
|
|
||||||
|
import type { RedisClientType } from './redis.types';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class RedisClientService {
|
export class RedisClientService {
|
||||||
private readonly clients = new Set<ioRedis | Cluster>();
|
private readonly clients = new Set<ioRedis | Cluster>();
|
||||||
|
@ -28,13 +26,6 @@ export class RedisClientService {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnShutdown(LOWEST_SHUTDOWN_PRIORITY)
|
|
||||||
disconnectClients() {
|
|
||||||
for (const client of this.clients) {
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure prefix is wrapped in curly braces for Redis cluster.
|
* Ensure prefix is wrapped in curly braces for Redis cluster.
|
||||||
* See: https://github.com/OptimalBits/bull/blob/develop/PATTERNS.md
|
* See: https://github.com/OptimalBits/bull/blob/develop/PATTERNS.md
|
||||||
|
|
Loading…
Reference in a new issue