diff --git a/cli/src/lib/conn.ts b/cli/src/lib/conn.ts index 267a3aff5..ab04ec9d1 100644 --- a/cli/src/lib/conn.ts +++ b/cli/src/lib/conn.ts @@ -48,6 +48,10 @@ const conn = (options: ConnectOptions) => { client.on('close', () => { basicLog.close() }) + + client.on('disconnect', () => { + basicLog.disconnect() + }) } const benchConn = async (options: BenchConnectOptions) => { @@ -119,6 +123,10 @@ const benchConn = async (options: BenchConnectOptions) => { connectedCount > 0 && (connectedCount -= 1) benchLog.close(connectedCount, count, opts.clientId!) }) + + client.on('disconnect', () => { + basicLog.disconnect(opts.clientId!) + }) })(i, connOpts) await delay(interval) diff --git a/cli/src/lib/pub.ts b/cli/src/lib/pub.ts index 1480d4dda..7a3f9cd43 100644 --- a/cli/src/lib/pub.ts +++ b/cli/src/lib/pub.ts @@ -141,6 +141,10 @@ const multisend = ( const { reconnectPeriod } = connOpts reconnectPeriod ? sender.cork() : process.exit(1) }) + + client.on('disconnect', () => { + basicLog.disconnect() + }) } const pub = (options: PublishOptions) => { @@ -326,6 +330,10 @@ const multiPub = async (commandType: CommandType, options: BenchPublishOptions | connectedCount > 0 && (connectedCount -= 1) benchLog.close(connectedCount, count, opts.clientId!) }) + + client.on('disconnect', () => { + basicLog.disconnect(opts.clientId!) + }) })(i, connOpts) await delay(interval) diff --git a/cli/src/lib/sub.ts b/cli/src/lib/sub.ts index 55ec97e56..cc2f081ff 100644 --- a/cli/src/lib/sub.ts +++ b/cli/src/lib/sub.ts @@ -141,6 +141,10 @@ const sub = (options: SubscribeOptions) => { client.on('close', () => { !outputModeClean && basicLog.close() }) + + client.on('disconnect', () => { + !outputModeClean && basicLog.disconnect() + }) } const benchSub = async (options: BenchSubscribeOptions) => { @@ -278,6 +282,10 @@ const benchSub = async (options: BenchSubscribeOptions) => { connectedCount > 0 && (connectedCount -= 1) benchLog.close(connectedCount, count, opts.clientId!) }) + + client.on('disconnect', () => { + basicLog.disconnect(opts.clientId!) + }) })(i, connOpts) await delay(interval) diff --git a/cli/src/utils/signale.ts b/cli/src/utils/signale.ts index 3cb7257a4..de01d795c 100644 --- a/cli/src/utils/signale.ts +++ b/cli/src/utils/signale.ts @@ -48,6 +48,8 @@ const basicLog = { close: () => signale.error('Connection closed'), reconnecting: () => signale.await('Reconnecting...'), reconnectTimesLimit: () => signale.error('Exceed the maximum reconnect times limit, stop retry'), + disconnect: (clientId?: string) => + signale.warn(`${clientId ? `Client ID: ${clientId}, ` : ''}The Broker has actively disconnected`), } const benchLog = {