Skip to content
Snippets Groups Projects
Commit 5c3a4925 authored by dakkar's avatar dakkar
Browse files

merge: Improve the check_connect script (!588)

View MR for information: TransFem-org/Sharkey!588



Approved-by: default avatarfEmber <acomputerdog@gmail.com>
Approved-by: default avatardakkar <dakkar@thenautilus.net>
Approved-by: default avatarMarie <marie@kaifa.ch>
parents 712af44d 0386e52d
No related branches found
No related tags found
No related merge requests found
......@@ -5,11 +5,33 @@
import Redis from 'ioredis';
import { loadConfig } from '../built/config.js';
import { createPostgresDataSource } from '../built/postgres.js';
const config = loadConfig();
const redis = new Redis(config.redis);
redis.on('connect', () => redis.disconnect());
redis.on('error', (e) => {
throw e;
});
// createPostgresDataSource handels primaries and replicas automatically.
// usually, it only opens connections first use, so we force it using
// .initialize()
createPostgresDataSource(config)
.initialize()
.then(c => { c.destroy() })
.catch(e => { throw e });
// Connect to all redis servers
function connectToRedis(redisOptions) {
const redis = new Redis(redisOptions);
redis.on('connect', () => redis.disconnect());
redis.on('error', (e) => {
throw e;
});
}
// If not all of these are defined, the default one gets reused.
// so we use a Set to only try connecting once to each **uniq** redis.
(new Set([
config.redis,
config.redisForPubsub,
config.redisForJobQueue,
config.redisForTimelines,
])).forEach(connectToRedis);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment