Autorun Server Django on Rasberry Pi 4

151 Views Asked by At

I have django server, which working corectly when I run rasberry then I open terminal in corrct folder then write :

source env/bin/activate python manage.py runserver 'my_ip:port

But I want to do this line automaticly when I turn on Rasberry So I have solution from youtube which work but not enough. I have directory /home/pi/.config/autostart in this directory i have file 'name_file.desktop'

in 'name_file.desktop' :

[Desktop Entry] Exec = bash /home/pi/Desktop/start.sh

Also I have file on my desktop 'start.sh'

in 'start.sh' :

cd /path/to/file source env/bin/activate cd /path/to/file python manage.py runserver 'my_ip:port'

And that work corectly. I turn on rasberry after about 20 seconds I see my desktop and I can connect to server Django with wi-fi with my mobile phone. But in this solution I must also connect monitor to Rasberry. When I have Rasberry without any output devices (like monitor). I only switch on rasberry and wait more time than 20 seconds and then i try and I can not connect to server Django with wi-fi with my mobile phone and I dont know why conecting monitor is nesscecery in this solution.

Has anybody have answer or other solution to autorun server Django when I only turn on raspbeery without output devices ?

0

There are 0 best solutions below