From 6b52403d05e1a590f5d814213f3d19656ae79871 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] =?UTF-8?q?=E8=B5=B7=E5=8B=95=E6=99=82=E3=81=ABRedis?= =?UTF-8?q?=E3=81=AE=E7=96=8E=E9=80=9A=E7=A2=BA=E8=AA=8D=E3=82=92=E8=A1=8C?= =?UTF-8?q?=E3=81=86=20(#9832)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 起動時にRedisの疎通確認を行う * check:connectをstart内に移動 --------- Co-authored-by: tamaina --- package.json | 3 ++- packages/backend/check_connect.js | 10 ++++++++++ packages/backend/package.json | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 packages/backend/check_connect.js diff --git a/package.json b/package.json index 11eae29af5..8d5334433b 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,11 @@ "scripts": { "build-pre": "node ./scripts/build-pre.js", "build": "pnpm build-pre && pnpm -r build && pnpm gulp", - "start": "cd packages/backend && node ./built/boot/index.js", + "start": "pnpm check:connect && cd packages/backend && node ./built/boot/index.js", "start:test": "cd packages/backend && cross-env NODE_ENV=test node ./built/boot/index.js", "init": "pnpm migrate", "migrate": "cd packages/backend && pnpm migrate", + "check:connect": "cd packages/backend && pnpm check:connect", "migrateandstart": "pnpm migrate && pnpm start", "gulp": "pnpm exec gulp build", "watch": "pnpm dev", 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 df78219985..2e8161308b 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -7,6 +7,7 @@ "start": "node ./built/index.js", "start:test": "NODE_ENV=test node ./built/index.js", "migrate": "pnpm typeorm migration:run -d ormconfig.js", + "check:connect": "node ./check_connect.js", "build": "swc src -d built -D", "watch:swc": "swc src -d built -D -w", "build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",