我正在尝试使用supervisor部署我的Django应用程序。当我启动supervisor时,它会正确启动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
答案 0 :(得分:1)
您可能需要设置DJANGO_SETTINGS_MODULE环境变量。
这个答案提供了一个例子:https://stackoverflow.com/a/26732916/4193
答案 1 :(得分:0)
您必须增加时间限制,并且每秒增加容量吞吐量高于100条消息
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [(XXX, XXX)],
"channel_capacity": {
"http.request": 200,
"websocket.send*": 20,
},
},
"ROUTING": "XXXXXchannel_routing"
},
}