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);
        }
    }
    

      

  • 相关阅读:
    Ubuntu16.04 LTS 安装VNC Server开启远程桌面
    duilib List右键菜单的响应
    centos bootloader安装到u盘后修复方法
    dpkg: error processing package XXX (--configure) 解决方法 (ubuntu右上角红色警告)
    linux centos ftp服务器搭建
    windows 端口转发 netsh
    遍历windows窗口
    解除文件占用
    VS 运行库MT、MD的区别
    点击显示桌面的窗口状态
  • 原文地址:https://www.cnblogs.com/firestar277/p/14604735.html
Copyright © 2011-2022 走看看