Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django:使服务器在不使用runserver的情况下继续运行_Python_Django_Django Channels - Fatal编程技术网

Python Django:使服务器在不使用runserver的情况下继续运行

Python Django:使服务器在不使用runserver的情况下继续运行,python,django,django-channels,Python,Django,Django Channels,我已经开始在我的服务器上使用django_频道。但是如果我想让websocket工作,我必须使用: python manage.py runserver 0.0.0.0:8080 服务器运行,我可以连接ws://myip:8080 netstat -nlp | grep :8080 但是,只要我按ctrl+c。它退出了,也就是说,我无法再连接ws://myip:8080 我想连续运行。您可以在后台运行,而无需挂断。 只需使用下面的命令 nohup python manage.py runse

我已经开始在我的服务器上使用django_频道。但是如果我想让websocket工作,我必须使用:

python manage.py runserver 0.0.0.0:8080
服务器运行,我可以连接
ws://myip:8080

netstat -nlp | grep :8080
但是,只要我按ctrl+c。它退出了,也就是说,我无法再连接
ws://myip:8080


我想连续运行。

您可以在后台运行,而无需挂断。 只需使用下面的命令

nohup python manage.py runserver 0.0.0.0:8080 &
杀死

查找端口上运行的pid
8080

netstat -nlp | grep :8080
然后在你得到pid之后

kill pidnumber

嘿,它起作用了。但是,你能解释一下它是如何工作的吗?如果我不想让它运行,你能解释一下如何杀死它吗。要杀死它,
sudo ps aux|grep-I'manage.py'
,找到进程id,
kill-9
@ericina,我在回答中也说过关于在后台运行的同样的事情。
runserver
只是为了开发,你不应该在生产中使用它。这里的答案告诉您如何在后台运行它,但这并不正确。你应该用daphne之类的东西我现在用gunicorn来完成这个任务。正如@MazelTov所说,runserver命令用于开发。查看此链接以了解如何设置gunicorn