- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个带有 Django Channels 的 Web 应用程序,在尝试使用 Supervisor 系统进行设置时遇到了问题。
首先,该应用程序在本地运行良好。
远程(我使用带有 Ubuntu Server 18.04 LTS 的 AWS EC2 实例),当使用命令 daphne -b 0.0.0.0 -p 8000 mysite.asgi:application
运行时它也运作良好。
但是,我不能让它与主管一起工作。我按照官方 Django Channels 文档( https://channels.readthedocs.io/en/latest/deploying.html )的说明进行操作,因此我有:
upstream channels-backend {
server localhost:8000;
}
server {
server_name www.example.com;
keepalive_timeout 5;
client_max_body_size 1m;
access_log /home/ubuntu/django_app/logs/nginx-access.log;
error_log /home/ubuntu/django_app/logs/nginx-error.log;
location /static/ {
alias /home/ubuntu/django_app/mysite/staticfiles/;
}
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_pass http://channels-backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
listen 80;
server_name www.example.com;
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
return 404; # managed by Certbot
}
[fcgi-program:asgi]
socket=tcp://localhost:8000
directory=/home/ubuntu/django_app/mysite
command=/home/ubuntu/django_app/venv/bin/daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0 --access-log - --proxy-headers mysite.asgi:application
numprocs=4
process_name=asgi%(process_num)d
autostart=true
autorestart=true
stdout_logfile=/home/ubuntu/django_app/logs/supervisor_log.log
redirect_stderr=true
2018-11-14 14:48:21,511 INFO Starting server at fd:fileno=0, unix:/run/daphne/daphne0.sock
2018-11-14 14:48:21,516 INFO HTTP/2 support enabled
2018-11-14 14:48:21,517 INFO Configuring endpoint fd:fileno=0
2018-11-14 14:48:22,015 INFO Listening on TCP address 127.0.0.1:8000
2018-11-14 14:48:22,025 INFO Configuring endpoint unix:/run/daphne/daphne0.sock
2018-11-14 14:48:22,026 CRITICAL Listen failure: [Errno 2] No such file or directory: '1416' -> b'/run/daphne/daphne0.sock.lock'
2018-11-14 14:48:22,091 INFO Starting server at fd:fileno=0, unix:/run/daphne/daphne2.sock
2018-11-14 14:48:22,096 INFO HTTP/2 support enabled
2018-11-14 14:48:22,097 INFO Configuring endpoint fd:fileno=0
2018-11-14 14:48:22,135 INFO Starting server at fd:fileno=0, unix:/run/daphne/daphne3.sock
2018-11-14 14:48:22,152 INFO HTTP/2 support enabled
2018-11-14 14:48:22,153 INFO Configuring endpoint fd:fileno=0
2018-11-14 14:48:22,237 INFO Listening on TCP address 127.0.0.1:8000
2018-11-14 14:48:22,241 INFO Listening on TCP address 127.0.0.1:8000
2018-11-14 14:48:22,242 INFO Configuring endpoint unix:/run/daphne/daphne3.sock
2018-11-14 14:48:22,242 CRITICAL Listen failure: [Errno 2] No such file or directory: '1419' -> b'/run/daphne/daphne3.sock.lock'
2018-11-14 14:48:22,252 INFO Configuring endpoint unix:/run/daphne/daphne2.sock
2018-11-14 14:48:22,252 CRITICAL Listen failure: [Errno 2] No such file or directory: '1420' -> b'/run/daphne/daphne2.sock.lock'
channels==2.1.2
channels-redis==2.2.1
daphne==2.2.1
Django==2.1.2
/run/daphne/daphne0.sock
,
/run/daphne/daphne1.sock
等,然后日志文件声明如下:
2018-11-15 10:24:38,289 INFO Starting server at fd:fileno=0, unix:/run/daphne/daphne0.sock
2018-11-15 10:24:38,290 INFO HTTP/2 support enabled
2018-11-15 10:24:38,280 INFO Configuring endpoint fd:fileno=0
2018-11-15 10:24:38,458 INFO Listening on TCP address 127.0.0.1:8000
2018-11-15 10:24:38,475 INFO Configuring endpoint unix:/run/daphne/daphne0.sock
2018-11-15 10:24:38,476 CRITICAL Listen failure: Couldn't listen on any:b'/run/daphne/daphne0.sock': [Errno 98] Address already in use.
最佳答案
在主管 ASGI 配置文件中,在以下行中command=/home/ubuntu/django_app/venv/bin/daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0 --access-log - --proxy-headers mysite.asgi:application
替换 --fd 0
与 --endpoint fd:fileno=0
.
问题:https://github.com/django/daphne/issues/234
关于nginx - 为 Daphne 配置 Supervisor(Django channel ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53304883/
我红了很多关于将 django channel 与 daphne 一起使用的教程,每个人都使用 nginx(或 apache,无所谓)作为反向代理?为什么需要反向代理?我不能只使用达芙妮进行生产吗?
我正在运行一个 Django Restserver 应用程序,由 Daphne 和 Nginx 充当反向代理。我还有一个定期的 cron 作业,它将更新的代码从我的 git 提取到服务器。 我无法找到
我将 Daphne 用于套接字和 http 连接。我正在运行 4 个工作容器,并且现在在一个 docker 容器中本地运行所有内容。 如果我尝试上传 400MB 的文件,我的 daphne 服务器会失
我有一个 Django Web 应用程序,它使用 Channels 和 Daphne 进行 Websocket 通信。我的所有 websocket 东西都工作正常,没有任何问题。 我的麻烦来自于我的服
我正在使用 Django 和 Django-Channels 部署一个网站,使用 Channel 的 daphne ASGI 服务器替代典型的 Gunicorn WSGI 设置。使用 this Gun
如果我在 Postman 或我们正在开发的 Android 应用程序中向我的 Daphne/Django 服务器发出请求,Daphne 会提供证书,但会被拒绝。如果我首先向 https://letse
我有一个 Django 应用程序,它使用 uWSGI 和 Nginx 进行生产部署。现在我正在集成 Channels 2.0,并意识到 Daphne 是 uwsgi 的替代品。在独立模式下运行时,我能
我已经使用 Nginx + uwsgi 设置了一个 Django 应用程序。该应用程序还使用 django-channels 和 redis。在单台计算机中部署设置时,一切正常。 但是当我尝试在 2
我的 django channel 有问题。我的 Django 应用程序与 WSGI 完美运行以处理 HTTP 请求。我尝试迁移到 channel 以允许 websocket 请求,结果发现在安装 c
到目前为止,我用过Gunicorn ,使用此配置文件 systemd: [Unit] Description=gunicorn daemon After=network.target [Service
我正在 Openshift 云上部署一个 Django 项目。该项目使用 channels和 Websockets 使其异步工作。问题是我无法从浏览器成功地将 websockets 连接到我在服务器端
我想将我的服务部署到 docker。 我的服务是使用 python+django 和 django-channels 开发的 ── myproject ├── myproject │ ├── sett
我创建了一个带有 Django Channels 的 Web 应用程序,在尝试使用 Supervisor 系统进行设置时遇到了问题。 首先,该应用程序在本地运行良好。 远程(我使用带有 Ubuntu
我在 heroku 上使用 Channels 2 创建了一个 django 应用程序,但它在启动时崩溃并显示 503 错误代码。 2020-04-07T10:05:35.226253+00:00 he
这是我的 nginx.conf: server { listen 80; location /proxy { proxy_pass http://0.0.0.0:800
我正在尝试让 django channel 与 daphne 一起运行,但我总是以这个结束 x8/backback/mysite » daphne mysite.asgi:application
我正在尝试让 django channel 与 daphne 一起运行,但我总是以这个结束 x8/backback/mysite » daphne mysite.asgi:application
我已经安装了 Django Channels。我正在尝试运行以下命令来运行 Daphne 服务器和工作人员。 > daphne chat.asgi:channel_layer --port $PORT
我正在使用 django-channels 为我的应用程序添加 HTTP2 和 WebSocket 支持。我找不到很多关于如何缩放 channel 的文档。下面是我的 nginx 配置,它对运行在同一
简短问题版本:我在 Daphne 配置、消费者代码或客户端代码中做错了什么? channels==1.1.8 daphne==1.3.0 Django==1.11.7 详情如下: 我正在尝试使用 Dj
我是一名优秀的程序员,十分优秀!