First of all, sorry for the long question, I hope a few of you have patience for this.
I am fol
I've just deployed my django channel app, and the following systemd service file worked for me without using supervisor:
/etc/systemd/system/django-channels-daphne.service
[Unit]
Description=daphne server script for my project
After=network.target
[Service]
User=webuser
Group=webuser
WorkingDirectory=/path/to/myproject
Environment=DJANGO_SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Environment=DJANGO_ALLOWED_HOSTS=myapp.chatbot.ai
ExecStart=/path/to/python/virtualenv/bin/daphne -b 0.0.0.0 -p 8000 myproject.asgi:channel_layer
Restart=always
[Install]
WantedBy=multi-user.target
/etc/systemd/system/django-channels-runworker.service
[Unit]
Description=python runworker server for myproject
After=network.target
[Service]
User=webuser
Group=webuser
WorkingDirectory=/path/to/myproject
Environment=DJANGO_SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Environment=DJANGO_ALLOWED_HOSTS=myapp.chatbot.ai
ExecStart=/path/to/python/virtualenv/bin/python /path/to/myproject/manage.py runworker --threads 4
Restart=always
[Install]
WantedBy=multi-user.target
/path/to/myproject/myproject/asgi.py
import os
import channels
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
channel_layer = channels.asgi.get_channel_layer()
Some lines in /path/to/myproject/myproject/settings.py:
ALLOWED_HOSTS = [os.environ['DJANGO_ALLOWED_HOSTS']]
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']