zoukankan      html  css  js  c++  java
  • 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);
        }
    }
    

      

  • 相关阅读:
    hdu 6201 dfs
    Oulipo POJ
    Kitchen Measurements UVALive
    Surf Gym
    hoj 13969 Racing Gems
    分块
    分块学习资料
    Jam's problem again HDU
    树的点分治
    Census UVA
  • 原文地址:https://www.cnblogs.com/firestar277/p/14604735.html
Copyright © 2011-2022 走看看