- Create a shell script with below content and save it as ‘runserver.sh’.
while true;
do
|
echo "Re-starting
Django Server"
|
python3
manage.py runserver 0.0.0.0:8000
|
sleep 2
|
done
- Start Django Server using the 'runserver.sh' script
- If the file was
created/edited in Windows environment, you might need to fix the line ending before
it can be executed in Linux PC. This can be done by executing below command –
sed -i
's/\r$//' runserver.sh
-
Make the shell script executable
chmod +x runserver.sh
- Execute shell script.
./runserver.sh
Now the server
will keep running.
- To stop the server, press ‘Ctrl+C’ twice.
Comments