• Binbin's avatar
    Print error messages in monitor/pubsub when errors occurs (#10050) · c57e41c0
    Binbin authored
    In monitor/pubsub mode, if the server closes the connection,
    for example, use `CLIENT KILL`, redis-cli will exit directly
    without printing any error messages.
    
    This commit ensures that redis-cli will try to print the
    error messages before exiting. Also there is a minor cleanup
    for restart, see the example below.
    
    before:
    ```
    127.0.0.1:6379> monitor
    OK
    [root@ redis]#
    
    127.0.0.1:6379> subscribe channel
    Reading messages... (press Ctrl-C to quit)
    1) "subscribe"
    2) "channel"
    3) (integer) 1
    [root@ redis]#
    
    127.0.0.1:6379> restart
    127.0.0.1:6379> get keyUse 'restart' only in Lua debugging mode.
    (nil)
    ```
    
    after:
    ```
    127.0.0.1:6379> monitor
    OK
    Error: Server closed the connection
    [root@ redis]#
    
    127.0.0.1:6379> subscribe channel
    Reading messages... (press Ctrl-C to quit)
    1) "subscribe"
    2) "channel"
    3) (integer) 1
    Error: Server closed the connection
    [root@ redis]#
    
    127.0.0.1:6379> restart
    Use 'restart' only in Lua debugging mode.
    ```
    c57e41c0
redis-cli.c 319 KB