zoukankan      html  css  js  c++  java
  • gunicorn运行显示connection in use解决办法

    运行gunicorn后显示如下错误:

    root@iZ2ze2gihbn4ot85zlcdxdZ:~/myproject# gunicorn -w 4 -b 0.0.0.0:5000 myapp:app
    [2018-03-16 15:48:33 +0800] [9555] [INFO] Starting gunicorn 19.7.1
    [2018-03-16 15:48:33 +0800] [9555] [ERROR] Connection in use: ('0.0.0.0', 5000)
    [2018-03-16 15:48:33 +0800] [9555] [ERROR] Retrying in 1 second.
    [2018-03-16 15:48:34 +0800] [9555] [ERROR] Connection in use: ('0.0.0.0', 5000)
    [2018-03-16 15:48:34 +0800] [9555] [ERROR] Retrying in 1 second.
    [2018-03-16 15:48:35 +0800] [9555] [ERROR] Connection in use: ('0.0.0.0', 5000)
    [2018-03-16 15:48:35 +0800] [9555] [ERROR] Retrying in 1 second.
    [2018-03-16 15:48:36 +0800] [9555] [ERROR] Connection in use: ('0.0.0.0', 5000)
    [2018-03-16 15:48:36 +0800] [9555] [ERROR] Retrying in 1 second.
    [2018-03-16 15:48:37 +0800] [9555] [ERROR] Connection in use: ('0.0.0.0', 5000)
    [2018-03-16 15:48:37 +0800] [9555] [ERROR] Retrying in 1 second.
    [2018-03-16 15:48:38 +0800] [9555] [ERROR] Can't connect to ('0.0.0.0', 5000)
    

      显示正在运行的gunicorn进程,发现没有已经运行zai 0.0.0.0:5000的进程:

    root@iZ2ze2gihbn4ot85zlcdxdZ:~/myproject# pstree -ap|grep gunicorn
      |                           |-grep,9539 --color=auto gunicorn

    这时查看服务器(主机)运行的全部进程:

    root@iZ2ze2gihbn4ot85zlcdxdZ:~/myproject# ps -a
      PID TTY          TIME CMD
     9446 pts/0    00:00:00 su
     9447 pts/0    00:00:00 bash
     9488 pts/0    00:00:00 sudo
     9489 pts/0    00:00:00 bash
     9514 pts/0    00:00:00 python3
     9516 pts/0    00:00:00 python3
     9551 pts/0    00:00:00 ps
    

      这时发现有两个python3的进程,其中有一个是运行的myapp.py文件的进程,而gunicorn要运行的就是该文件,因此产生冲突。

    删掉进程:

    root@iZ2ze2gihbn4ot85zlcdxdZ:~/myproject# kill -9 9516
    [2]+  Killed                  python3 myapp.py
    

     这时再运行gunicorn就好了:

    root@iZ2ze2gihbn4ot85zlcdxdZ:~/myproject# gunicorn -w 4 -b 0.0.0.0:5000 myapp:app
    [2018-03-16 15:49:41 +0800] [9558] [INFO] Starting gunicorn 19.7.1
    [2018-03-16 15:49:41 +0800] [9558] [INFO] Listening at: http://0.0.0.0:5000 (9558)
    [2018-03-16 15:49:41 +0800] [9558] [INFO] Using worker: sync
    [2018-03-16 15:49:41 +0800] [9561] [INFO] Booting worker with pid: 9561
    [2018-03-16 15:49:41 +0800] [9563] [INFO] Booting worker with pid: 9563
    [2018-03-16 15:49:41 +0800] [9564] [INFO] Booting worker with pid: 9564
    [2018-03-16 15:49:42 +0800] [9565] [INFO] Booting worker with pid: 9565
    

      

  • 相关阅读:
    LeetCode 189. Rotate Array
    LeetCode 965. Univalued Binary Tree
    LeetCode 111. Minimum Depth of Binary Tree
    LeetCode 104. Maximum Depth of Binary Tree
    Windows下MySQL的安装与配置
    LeetCode 58. Length of Last Word
    LeetCode 41. First Missing Positive
    LeetCode 283. Move Zeroes
    《蚂蚁金服11.11:支付宝和蚂蚁花呗的技术架构及实践》读后感
    删除docker下的镜像
  • 原文地址:https://www.cnblogs.com/IcarusYu/p/8582894.html
Copyright © 2011-2022 走看看