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

  

 

转载于:https://www.cnblogs.com/IcarusYu/p/8582894.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值