A little tip Tim - your one-liner can also be achieved with the pkill
utility: pkill -u $USER -f manage.py runserver . The user matching with -u
$USER flag is cautious but probably unnecessary.

https://linux.die.net/man/1/pkill

On Tue, 8 Sep 2020 at 10:48, Tim Allen <flip...@peregrinesalon.com> wrote:

> The advice here is solid, but to answer the initial query... i created a
> one liner to kill any runservers from my current user, as they can get lost
> in my sea of terminals. This may help:
>
> alias kill-runserver="ps -eaf | grep 'manage.py runserver' |
> grep "'$USER'" | grep -v grep | awk '{print "'$2'"}' | xargs kill -9"
>
> Good luck!
>
> On Monday, September 7, 2020 at 9:37:50 AM UTC-4 tond...@gmail.com wrote:
>
>> Hello there,
>>
>> This question on StackOverflow is a workaround for stopping the server
>>
>> https://stackoverflow.com/questions/27066366/django-development-server-how-to-stop-it-when-it-run-in-background
>>
>> Basically I would like to run the server and stop it by a program, it is
>> hard, when the default way is literally "pressing ctrl+C",
>> killing the process is different on different OS'es.
>> When searching the web (StackOverflow) users replies to individual
>> answers were "This worked for me." or "This didn't work for me.",
>> this showcases that different conditions make it hard to get to actually
>> stopping the server.
>>
>> A unified solution would be very nice. If we want to keep "python
>> manage.py runserver" together with "press ctrl+C to quit",
>> then I would suggest a new command, let's call it "startserver", that
>> would be non-blocking, running subprocess, or something,
>> once the user is done he simply calls "stopserver" to stop it.
>> "startserver" vs "runserver" might be similar for some, suggest different
>> command name if you like.
>>
>> It is only my suggestion, I don't care if it will be more complicated as
>> long as it will "just work" on all OS'es and will be clear to use.
>>
>> Thanks for your time and consideration
>> Antonín Drdácký
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/5712fd9d-2555-45f2-ad7c-3e4d05b65660n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/5712fd9d-2555-45f2-ad7c-3e4d05b65660n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM1%3DGOr9hjw7d5kA6iscGzykftif1ff9xrJPWQLXj0e63A%40mail.gmail.com.

Reply via email to