Save
Saving
  • G
    guluting

    将以下文件保存到:/etc/nginx/conf.d/http.conf

    upstream servers {
        server localhost:8001;
        server localhost:8002;
        server localhost:8003;
        server localhost:8004;
    }
    
    server {
        listen 9000;
    
        location / {
            proxy_pass  http://servers;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_redirect off;
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
       }
    }
    
    

    然后运行(CentOS):systemctl restart nginx
    即可将9000端口上的请求转发到本机的:8001,8002,8003,8004端口

    posted in GuaiK机房 read more
  • G
    guluting

    原因:time.sleep是一个阻塞 函数,它不允许控制权返回到IOLoop去执行其他处理程序,所以会造成请求的阻塞。

    可以使用:tornado.gen.sleep代替time.sleeptornado中使用。

    posted in GuaiK实验室 read more
  • G
    guluting

    pyenv报错:xcrun: error: invalid active developer path
    运行:xcode-select --install

    ERROR: The Python zlib extension was not compiled. Missing the zlib?
    运行:

    brew install zlib
    CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 2.7.15
    

    posted in GuaiK机房 read more
  • G
    guluting

    vi /etc/environment

    # 加入以下两行
    LANG=en_US.utf-8
    LC_ALL=en_US.utf-8
    

    posted in GuaiK机房 read more
  • G
    guluting

    解决方案:
    ssh-keygen -R [remote_ip]

    posted in GuaiK机房 read more
  • G
    guluting

    @裸奔的de饺子
    再告诉你一个好玩的东西,可以将所有的IO都变成异步的。
    使用gevent的“猴子补丁”
    pip install gevent

    # 在代码头部加入代码
    from gevent import monkey
    monkey.patch_all()
    

    posted in GuaiK实验室 read more
  • G
    guluting

    @裸奔的de饺子
    这不就是个自定义的注解嘛,so,注解==黑魔法咯 😒

    posted in GuaiK实验室 read more
  • G
    guluting

    yum -y install epel-release
    yum -y install erlang socat
    wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
    rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
    rpm -Uvh rabbitmq-server-3.6.10-1.el7.noarch.rpm
    systemctl start rabbitmq-server
    systemctl enable rabbitmq-server
    systemctl status rabbitmq-server
    

    可能会用到的端口:

    firewall-cmd --zone=public --permanent --add-port=4369/tcp
    firewall-cmd --zone=public --permanent --add-port=25672/tcp
    firewall-cmd --zone=public --permanent --add-port=5671-5672/tcp
    firewall-cmd --zone=public --permanent --add-port=15672/tcp
    firewall-cmd --zone=public --permanent --add-port=61613-61614/tcp
    firewall-cmd --zone=public --permanent --add-port=1883/tcp
    firewall-cmd --zone=public --permanent --add-port=8883/tcp
    firewall-cmd --reload
    setsebool -P nis_enabled 1
    

    打开web可视化界面
    rabbitmq-plugins enable rabbitmq_management

    权限设置
    chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/

    添加管理员账户

    rabbitmqctl add_user admin [passwd]
    rabbitmqctl set_user_tags admin administrator
    rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
    

    访问RabbitMQ WEB管理界面:
    http://localhost:15672

    posted in GuaiK实验室 read more
  • G
    guluting

    @裸奔的de饺子
    gevent底层采用了greenlet实现协程,协程并非多进程也不是多线程😒
    协程是单线程,所以比多线程省去了切换的开销。由于是单线程,也不需要使用锁机制。
    如果想充分利用CPU多核的优势,那么可以使用多进程+协程。😀

    posted in GuaiK实验室 read more