eternal-flame-AD
109d8f8008
All checks were successful
Test (production install and build) / production (22.11.0) (push) Successful in 1m53s
Lint / pnpm_install (pull_request) Successful in 1m36s
Publish Docker image / Build (push) Successful in 5m12s
Publish Docker image / Build (pull_request) Successful in 4m28s
Test (production install and build) / production (22.11.0) (pull_request) Successful in 1m13s
Lint / lint (backend) (pull_request) Successful in 2m47s
Test (backend) / unit (22.11.0) (pull_request) Successful in 8m38s
Lint / lint (frontend-embed) (pull_request) Successful in 2m25s
Test (backend) / e2e (22.11.0) (pull_request) Successful in 11m35s
Lint / lint (frontend-shared) (pull_request) Successful in 2m28s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m37s
Lint / lint (frontend) (pull_request) Successful in 9m50s
Lint / lint (misskey-js) (pull_request) Successful in 2m27s
Lint / lint (sw) (pull_request) Successful in 2m45s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m58s
Lint / typecheck (backend) (pull_request) Successful in 2m42s
Lint / typecheck (misskey-js) (pull_request) Successful in 1m49s
Lint / typecheck (sw) (pull_request) Successful in 1m59s
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import Redis from 'ioredis';
|
|
import { loadConfig } from '../built/config.js';
|
|
import { createPostgresDataSource } from '../built/postgres.js';
|
|
|
|
const config = loadConfig();
|
|
|
|
async function connectToPostgres() {
|
|
const source = createPostgresDataSource(config);
|
|
await source.initialize();
|
|
await source.destroy();
|
|
}
|
|
|
|
async function connectToRedis(redisOptions) {
|
|
return await new Promise(async (resolve, reject) => {
|
|
const redis = new Redis({
|
|
...redisOptions,
|
|
lazyConnect: true,
|
|
reconnectOnError: false,
|
|
showFriendlyErrorStack: true,
|
|
connectTimeout: 10000,
|
|
});
|
|
redis.on('error', e => reject(e));
|
|
|
|
try {
|
|
await redis.connect();
|
|
resolve();
|
|
|
|
} catch (e) {
|
|
reject(e);
|
|
|
|
} finally {
|
|
redis.disconnect(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 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.
|
|
const promises = Array
|
|
.from(new Set([
|
|
config.redis,
|
|
config.redisForPubsub,
|
|
config.redisForJobQueue,
|
|
config.redisForTimelines,
|
|
config.redisForReactions,
|
|
]))
|
|
.map(connectToRedis)
|
|
.concat([
|
|
connectToPostgres().then(() => { console.log('Connected to PostgreSQL.'); }),
|
|
]);
|
|
|
|
await Promise.allSettled(promises);
|
|
|
|
process.exit(0);
|