Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud 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?

like image 242
bricks Avatar asked Nov 21 '14 16:11

bricks


People also ask

How do I stop Django running in the background?

You can Quit the server by hitting CTRL-BREAK. Not if it's in the background.

How do I keep Django server running?

Start your server there. Then press Ctrl-a, then d. This detach the screen session, keeping it running in the background.

How do I stop Django shell?

You can simply use CTRL+C to quit your server .


1 Answers

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...

like image 55
user Avatar answered Sep 29 '22 16:09

user