3

我正在尝试使用主管部署我的 Django 应用程序。当我启动主管时,它会正确启动 daphne,但是不会启动工作服务器。

这是 supervisor.conf 的代码示例(工人块):

[program:runworker]
command=python /home/django/environment/myproject/manage.py runworker
stopsignal=KILL
killasgroup=true

浏览器等待了很长时间,然后显示:

 503 Service Unavailable
Worker server failed to respond within time limit.

我还可以补充一点,如果我独立启动流程(不使用任何流程控制系统),它实际上可以工作。我在 Nginx 反向代理后面,但我认为这根本不是问题..

这是主管的输出:

2016-08-17 19:01:09,439 INFO supervisord started with pid 3473
2016-08-17 19:01:10,441 INFO spawned: 'runworker' with pid 3477
2016-08-17 19:01:10,442 INFO spawned: 'daphne' with pid 3478
2016-08-17 19:01:11,421 DEBG 'daphne' stderr output:
2016-08-17 23:01:11,421 INFO Starting server at 0.0.0.0:9000, channel layer myproject.asgi:channel_layer

2016-08-17 19:01:11,519 INFO success: runworker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-08-17 19:01:11,519 INFO success: daphne entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-08-17 19:01:11,591 DEBG 'runworker' stderr output:
2016-08-17 23:01:11,591 - INFO - runworker - Running worker against channel layer default (asgi_redis.core.RedisChannelLayer)

2016-08-17 19:01:11,592 DEBG 'runworker' stderr output:
2016-08-17 23:01:11,592 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
4

2 回答 2

1

您必须增加时间限制并且增加容量吞吐量高于每秒 100 条消息

CHANNEL_LAYERS = {
        "default": {
            "BACKEND": "asgi_redis.RedisChannelLayer",
            "CONFIG": {
                "hosts": [(XXX, XXX)],
                "channel_capacity": {
                    "http.request": 200,
                    "websocket.send*": 20,
                },
            },
            "ROUTING": "XXXXXchannel_routing"
        },
    }
于 2018-02-16T07:36:08.353 回答
1

您可能需要设置 DJANGO_SETTINGS_MODULE 环境变量。

这个答案提供了一个例子:https ://stackoverflow.com/a/26732916/4193

于 2016-08-17T23:15:06.907 回答