Last active
August 21, 2016 17:02
-
-
Save benregn/9481538 to your computer and use it in GitHub Desktop.
function to kill whatever is running on port 8000 and start `runserver_plus` using port 8000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| function start_runserver_plus() { | |
| cd /path/to/project/dir && workon myvenv && python manage.py runserver_plus 0.0.0.0:8000 --traceback -v 3 --threaded | |
| } | |
| function rs() { | |
| # lsof -i :8000 lists processes using the 8000 port, -t option returns only the process ID | |
| d_pid=`lsof -t -i :8000` | |
| if [[ $d_pid ]]; then | |
| echo "something is using 8000... Killing it!" | |
| kill -9 $d_pid | |
| echo "starting server..." | |
| start_runserver_plus | |
| else | |
| echo "nothing to kill... starting server..." | |
| start_runserver_plus | |
| fi | |
| } | |
| rs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do i run it please.