django development server, how to stop it when it run in background

喜欢而已 提交于 2019-12-03 07:27:57

问题


I use a clode server to test my django small project , I type in manage.py runserver & ,and then I log out my cloude server ,I can visit mysite normally but when I reload my cloude server , I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?


回答1:


The answer is findable via Google -- and answered in other forums. Example solution is available on the Unix & Linux StackExchange site.

To be explicit, you could do:

ps auxw | grep runserver

This will return the process and its respective PID, such as:

de        7956  1.8  0.6 540204 55212 ?        Sl   13:27   0:09 /home/de/Development/sampleproject/bin/python ./manage.py runserver

In this particular case, the PID is 7956. Now just run this to stop it:

kill 7956

And to be clear / address some of the comments, you have to do it this way because you're running the development server in the background (the & in your command). That's why there is no "built-in" Django stop option...




回答2:


One liner..

pkill -f runserver



回答3:


well it seems that it's a bug that django hadn't provided a command to stop the development server . I thought it have one before~~~~~




回答4:


As far as i know ctrl+c or kill process is only ways to do that on remote machine. If you will use Gunicorn server or somethink similar you will be able to do that using Supervisor.




回答5:


From task manager you can end the python tasks that are running. Now run python manage.py runserver from your project directory and it will work.




回答6:


We can use the following command.

-> netstat -ntlp

then we will get number of process running with PID, find our python server PID and Kill process.

-> kill -9 PID

For example:




回答7:


You can Quit the server by hitting CTRL-BREAK.



来源:https://stackoverflow.com/questions/27066366/django-development-server-how-to-stop-it-when-it-run-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!