From ea5725b986a6922c0a1c21994231d65109af0756 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:09:17 +0900 Subject: [PATCH] Check redis connection --------- Co-authored-by: tamaina --- package.json | 2 +- packages/backend/check_connect.js | 10 ++++++++++ packages/backend/package.json | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 packages/backend/check_connect.js diff --git a/package.json b/package.json index 11a539409e..cc44c64682 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "rebuild": "pnpm run clean && pnpm -r run build && pnpm run gulp", "build": "pnpm -r run build && pnpm run gulp", - "start": "pnpm --filter backend run start", + "start": "pnpm check:connect && pnpm --filter backend run start", "start:test": "pnpm --filter backend run start:test", "init": "pnpm run migrate", "migrate": "pnpm --filter backend run migrate", diff --git a/packages/backend/check_connect.js b/packages/backend/check_connect.js new file mode 100644 index 0000000000..8bf134a105 --- /dev/null +++ b/packages/backend/check_connect.js @@ -0,0 +1,10 @@ +import {loadConfig} from './built/config.js'; +import {createRedisConnection} from "./built/redis.js"; + +const config = loadConfig(); +const redis = createRedisConnection(config); + +redis.on('connect', () => redis.disconnect()); +redis.on('error', (e) => { + throw e; +}); diff --git a/packages/backend/package.json b/packages/backend/package.json index 55a64191a3..f3aaafc9a2 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -8,6 +8,7 @@ "start:test": "NODE_ENV=test pnpm node ./built/index.js", "migrate": "typeorm migration:run -d ormconfig.js", "revertmigration": "typeorm migration:revert -d ormconfig.js", + "check:connect": "node ./check_connect.js", "build": "pnpm swc src -d built -D", "watch": "pnpm swc src -d built -D -w", "lint": "pnpm rome check \"src/**/*.ts\"",