How to exit a Django development server using a bash script?

I wrote a bash script to start Django forks, however I want to leave the server while it is working with the bash script. I am writing a web application for Koding.com that launches a Django process in an online terminal connected to a user's personal virtual machine by running a bash script with a click of a button, and I want users to be able to complete the process with a click of a button. I know that C control will complete the process, but I could not find out how to do this in a bash script. How could I do this? Thank you enter image description here

UPDATE: I ultimately combined my selected answer for this question and this answer from another question I asked (how to run unix commands in the django shell) to solve my problem: https://stackoverflow.com/a/316618/

+4
3

8000/TCP:

fuser -k 8000/tcp

fuser , , , -k .

, , django, unix?

, , . , , CTRL+Z, bg ( , bash ). jobs , . fg.

. bash (man bash).

+7

GNU? http://www.gnu.org/software/screen/

screen
./manage.py runserver 0.0.0.0:8000
ctrl + a then d (this will detach from screen)
exit (from the shell)

,

screen -r
ctrl + c
exit (from screen)
exit (from the shell)

~/.screenrc

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
+1

You can simply use CTRL+Cto exit your server.
otherwise with ubuntu you can do as shown below.

prashant@prashant-OptiPlex-3010:~$  ps -eaf|grep runserver
prashant  3445  2805  4 11:20 pts/0    00:00:00 python manage.py runserver
prashant  3446  3445  5 11:20 pts/0    00:00:00 /usr/bin/python manage.py runserver
prashant  3449  3375  0 11:20 pts/1    00:00:00 grep --color=auto runserver
prashant@prashant-OptiPlex-3010:~$ kill 3446
prashant@prashant-OptiPlex-3010:~$ 
0
source

Source: https://habr.com/ru/post/1534349/


All Articles