yumechi-no-kuni/packages/backend/scripts/check_connect.js
eternal-flame-AD 4d44adfaa9
Some checks failed
Lint / pnpm_install (push) Successful in 2m1s
Publish Docker image / Build (push) Successful in 5m10s
Test (production install and build) / production (22.11.0) (push) Successful in 1m25s
Lint / lint (backend) (push) Successful in 2m7s
Lint / lint (frontend) (push) Successful in 2m11s
Lint / lint (frontend-embed) (push) Successful in 2m9s
Lint / lint (frontend-shared) (push) Successful in 2m19s
Lint / lint (misskey-bubble-game) (push) Successful in 2m21s
Lint / lint (misskey-reversi) (push) Successful in 2m33s
Lint / lint (misskey-js) (push) Successful in 2m44s
Lint / typecheck (misskey-js) (push) Successful in 1m23s
Lint / lint (sw) (push) Successful in 2m21s
Lint / typecheck (backend) (push) Successful in 2m3s
Lint / typecheck (sw) (push) Successful in 1m23s
Lint / pnpm_install (pull_request) Successful in 1m35s
Publish Docker image / Build (pull_request) Successful in 4m59s
Test (production install and build) / production (22.11.0) (pull_request) Successful in 1m32s
Test (backend) / e2e (22.11.0) (push) Failing after 1m56s
Lint / lint (backend) (pull_request) Successful in 2m0s
Lint / lint (frontend) (pull_request) Successful in 2m16s
Lint / lint (frontend-embed) (pull_request) Successful in 2m3s
Lint / lint (frontend-shared) (pull_request) Successful in 2m9s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m7s
Test (backend) / unit (22.11.0) (push) Failing after 10m2s
Lint / lint (misskey-js) (pull_request) Successful in 2m13s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m16s
Lint / lint (sw) (pull_request) Successful in 2m26s
Lint / typecheck (misskey-js) (pull_request) Successful in 1m29s
Lint / typecheck (backend) (pull_request) Successful in 2m16s
Lint / typecheck (sw) (pull_request) Successful in 1m40s
Test (backend) / e2e (22.11.0) (pull_request) Failing after 2m5s
Test (backend) / unit (22.11.0) (pull_request) Failing after 7m45s
prometheus - stage 1 deployment
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2024-11-17 04:44:39 -06:00

63 lines
1.4 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 timeout = setTimeout(() => {
console.error('Timeout while connecting to databases.');
process.exit(1);
}, 120000);
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,
});
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);
clearTimeout(timeout);