Django Server¶
Install Redis¶
Redis improves performance by storing frequently accessed data in memory, reducing database queries. It is used in Django for caching, session management, and as a message broker to improve performance and enable real-time features. To speed up cache access, the faster in-memory cache Redis is used.
Install Redis:
sudo apt-get install redis-server
Ensure that the Redis server is running:
sudo service redis-server start
Django Service¶
According to the following description a service has been created for Django Server. The description both includes Google Cloud Platform and Raspberry Pi.
django-server.service
Script django-server.service installed in directory /etc/systemd/system/. The Script starts the Django Server on Debian Linux.
Example of the script django-server.service:
sudo nano /etc/systemd/system/django-server.service
Content:
[Unit]
Description=Handling of the Django Server
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/local/logistics/Python/venv/django_webapps_fullstack/bin/python3 \
/usr/local/logistics/Python/repo/django_webapps_fullstack/manage.py \
runserver --insecure 0:8000 \
--certificate /etc/letsencrypt/live/dingx.co/fullchain.pem \
--key /etc/letsencrypt/live/dingx.co/privkey.pem
Restart=on-abort
[Install]
WantedBy=multi-user.target
Start and Stop of the Server
Reload Systemd to read the new service unit file:
sudo systemctl daemon-reload
Enable the service to start at boot:
sudo systemctl enable django-server
Start of the Server
sudo systemctl start django-server
Stop of the Server
sudo systemctl stop django-server
Status of the Server
sudo systemctl status django-server