From 8bf7232da2d462b819127a86d37d1358eab1a3e3 Mon Sep 17 00:00:00 2001 From: zhl Date: Sat, 30 Jan 2021 12:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E7=94=9F=E4=BA=A7=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=89=8D=E4=BD=BF=E7=94=A8=E6=9C=8D=E5=8A=A1=E8=87=AA?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/system.util.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils/system.util.ts b/src/utils/system.util.ts index 8d5dcbb..f742a3f 100644 --- a/src/utils/system.util.ts +++ b/src/utils/system.util.ts @@ -5,6 +5,7 @@ const signals: NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGUSR2'] const NODES_SET = 'poker:infosvr' const discovery_channel = 'poker:infosvr:discovery' +const isProd = process.env.NODE_ENV === 'production' export function registerGracefulShutdown(callback: (err?: Error) => void) { /** @@ -26,6 +27,9 @@ async function getNodeAddress(port: number) { } export async function registService(port: number) { + if (!isProd) { + return + } const address = await getNodeAddress(port) const client = new RedisClient() await client.sadd(NODES_SET, address) @@ -33,6 +37,9 @@ export async function registService(port: number) { } export async function unRegistService(port: number) { + if (!isProd) { + return + } const address = await getNodeAddress(port) const client = new RedisClient() await client.srem(NODES_SET, address)