Skip to content

Instantly share code, notes, and snippets.

@benregn
Last active August 21, 2016 17:02
Show Gist options
  • Select an option

  • Save benregn/9481538 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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
@saviour123
Copy link
Copy Markdown

how do i run it please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment