我看过互联网,包括StackOverflow,并且看到了类似的问题,但几个小时后我感到难过。
我可以添加任何人认为可能有用的信息。 我在DigitalOcean Droplet Ubuntu14.0.4中,在virtualenv中名为' sod22',使用Python3.4,Django1.8,Gunicorn19.4.5,nginx1.4.6 这是我在Bash中的错误输出:
(sod22) root@ShapeOfData2:~/.virtualenvs/sod22# gunicorn --bind 0.0.0.0:8000 sod22.wsgi:application
[2016-01-27 02:25:18 -0500] [25609] [INFO] Starting gunicorn 19.4.5
[2016-01-27 02:25:18 -0500] [25609] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2016-01-27 02:25:18 -0500] [25609] [ERROR] Retrying in 1 second.
[2016-01-27 02:25:19 -0500] [25609] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2016-01-27 02:25:19 -0500] [25609] [ERROR] Retrying in 1 second.
[2016-01-27 02:25:20 -0500] [25609] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2016-01-27 02:25:20 -0500] [25609] [ERROR] Retrying in 1 second.
[2016-01-27 02:25:21 -0500] [25609] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2016-01-27 02:25:21 -0500] [25609] [ERROR] Retrying in 1 second.
[2016-01-27 02:25:22 -0500] [25609] [ERROR] Connection in use: ('0.0.0.0', 8000)
[2016-01-27 02:25:22 -0500] [25609] [ERROR] Retrying in 1 second.
[2016-01-27 02:25:23 -0500] [25609] [ERROR] Can't connect to ('0.0.0.0', 8000)
我已经使用netstat检查了可能在端口8000上运行的进程:
(sod22) root@ShapeOfData2:~/.virtualenvs/sod22# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16069/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3411/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 14574/postgres
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 25638/python3.4
tcp6 0 0 :::80 :::* LISTEN 16069/nginx
tcp6 0 0 :::22 :::* LISTEN 3411/sshd
我已杀死所有Gunicorn进程,但获得相同的行为。但是,使用不同的命令,我的控制台似乎会锁定'并且网页上仍然没有输出:
(sod22) root@ShapeOfData2:~/.virtualenvs/sod22# gunicorn sod22.wsgi:application
[2016-01-27 02:27:17 -0500] [25638] [INFO] Starting gunicorn 19.4.5
[2016-01-27 02:27:17 -0500] [25638] [INFO] Listening at: http://127.0.0.1:8000 (25638)
[2016-01-27 02:27:17 -0500] [25638] [INFO] Using worker: sync
[2016-01-27 02:27:17 -0500] [25641] [INFO] Booting worker with pid: 25641
此时没有光标可以尝试其他任何操作,此时不会杀死控制台。
Per Sayse的建议,我在杀死进程后检查了进程和结果。也许Python正在使用port:8000并在它被杀后不断刷新?请参阅下文,请注意,在该过程被终止后,我再次检查,然后再次运行:
(sod22) root@ShapeOfData2:~/.virtualenvs/sod22# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16069/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3411/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 14574/postgres
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 25638/python3.4
tcp6 0 0 :::80 :::* LISTEN 16069/nginx
tcp6 0 0 :::22 :::* LISTEN 3411/sshd
(sod22) root@ShapeOfData2:~/.virtualenvs/sod22# kill 25638
(sod22) root@ShapeOfData2:~/.virtualenvs/sod22# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16069/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3411/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 14574/postgres
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 25638/python3.4
tcp6 0 0 :::80 :::* LISTEN 16069/nginx
tcp6 0 0 :::22 :::* LISTEN 3411/sshd
提前致谢。当然,我并不是唯一经历过这种情况的人!