• Redis-cli command to restart the redis server


    I terminated the redis server using SHUTDOWN from redis-cli. Now the prompt shows 'not connected>'.

    The only way I found to restart the server was to exit the redis-cli prompt and then do a restart of the redis service.

    My question is, is there any way to restart the server from the redis-cli prompt using any redis commands WITHOUT EXITING the redis-cli prompt?

    i agree Itamar Haber answer and i will uncover the details

    after the server restart,if you type any command in this 'not connected>',the redis-cli will attempt connect again if send command failed.

    while (1) {
            config.cluster_reissue_command = 0;
            if (cliSendCommand(argc,argv,repeat) != REDIS_OK) {
                cliConnect(1);//try to connect redis server if sendcommand failed
    
                if (cliSendCommand(argc,argv,repeat) != REDIS_OK) {//after try to connect,send commend again
                    cliPrintContextError();
                    return REDIS_ERR;
                }
             }
        }
    

      

    after redis-server restart successfully,it will listen socket event,if socket connect occur,server will accept connect at here

    void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    ......some code.......
    while(max--) {
            cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);//accept connect
            if (cfd == ANET_ERR) {
                if (errno != EWOULDBLOCK)
                    serverLog(LL_WARNING,
                        "Accepting client connection: %s", server.neterr);
                return;
            }
            serverLog(LL_VERBOSE,"Accepted %s:%d", cip, cport);
            acceptCommonHandler(cfd,0,cip);
        }
    }
    

      

  • 相关阅读:
    stm32 IO模式
    stm32的ADC
    bsp
    stm32的硬件调试设置
    RTC实时时钟
    快手2019笔试题 “回文子串" 解题思路
    C++内存修改器开源代码
    FC游戏修改教程(hack)小白文。
    GLFW+GLEW搭建opengl环境(备忘)
    8086 IO读写操作
  • 原文地址:https://www.cnblogs.com/firestar277/p/14604735.html
Copyright © 2020-2023  润新知