Ошибка развертывания Daphne Django 'Exited with status 1/FAILURE' на linux

Я боролся с этой ошибкой в течение нескольких часов, когда я пытаюсь запустить свой daphne.service, появляется эта ошибка после выполнения команды systemctl status daphne.service. Я следую этому руководству: https://github.com/mitchtabian/HOWTO-django-channels-daphne. Я использую Gunicorn, Nginx и Redis, которые работают правильно.

Ошибка:

× daphne.service - WebSocket Daphne Service
     Loaded: loaded (/etc/systemd/system/daphne.service; disabled; preset: enabled)
     Active: failed (Result: exit-code) since Sun 2024-04-21 00:37:25 UTC; 31s ago
   Duration: 676ms
    Process: 2998 ExecStart=/home/franreinaudo/venv/bin/python /home/franreinaudo/venv/bin/daphne -b 0.0.0.0 -p 8001 core.asgi:application (code=exited, status=1/F>
   Main PID: 2998 (code=exited, status=1/FAILURE)
        CPU: 673ms

Apr 21 00:37:25 test-db.southamerica-west1-a.c.farm-control-test.internal systemd[1]: daphne.service: Scheduled restart job, restart counter is at 5.
Apr 21 00:37:25 test-db.southamerica-west1-a.c.farm-control-test.internal systemd[1]: Stopped daphne.service - WebSocket Daphne Service.
Apr 21 00:37:25 test-db.southamerica-west1-a.c.farm-control-test.internal systemd[1]: daphne.service: Start request repeated too quickly.
Apr 21 00:37:25 test-db.southamerica-west1-a.c.farm-control-test.internal systemd[1]: daphne.service: Failed with result 'exit-code'.
Apr 21 00:37:25 test-db.southamerica-west1-a.c.farm-control-test.internal systemd[1]: Failed to start daphne.service - WebSocket Daphne Service.

daphne.service

[Unit]
Description=WebSocket Daphne Service
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/home/franreinaudo/test-db
ExecStart=/home/franreinaudo/venv/bin/python /home/franreinaudo/venv/bin/daphne -b 0.0.0.0 -p 8001 core.asgi:application
Restart=on-failure

[Install]
WantedBy=multi-user.target

settings.py

asgi.py

"""
ASGI config for core project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
"""

import os
import farms.routing
import django

from channels.routing import ProtocolTypeRouter, URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
from django_channels_jwt_auth_middleware.auth import JWTAuthMiddlewareStack
from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
django.setup()

django_asgi_app = get_asgi_application()

application = ProtocolTypeRouter({
    'http': django_asgi_app,
    'websocket': AllowedHostsOriginValidator(
        JWTAuthMiddlewareStack(
            URLRouter(farms.routing.websocket_urlpatterns)
        )
    )
})

Вернуться на верх