本文主要是介绍使用supervisor管理daphne进程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
supervisor是由python实现的一个进程管理工具,可以确保所管理的进程一直运行,当进程一点中断supervisord会自动进行重启。
安装
pip install supervisor
生成配置文件
这里我是在项目目录执行,生成在了项目目录下,可以自行换成etc目录
echo_supervisord_conf > supervisord.conf
1
2
对配置文件增加配置
[program:daphne]
directory=/home/arrow/bmxf #项目目录
command=daphne -b 127.0.0.1 -p 8991 --proxy-headers bmxf.asgi:application #启动命令
autostart=true
autorestart=true
stdout_logfile=/tmp/websocket.log #日志
redirect_stderr=true
1
2
3
4
5
6
7
启用
supervisord -c supervisord.conf
supervisorctl start daphne
supervisorctl stop daphne # 停止daphne
1
2
3
测试后发现websocket没有出错。
转载:https://www.cnblogs.com/wdliu/p/10032180.html
修改supervisord.conf文件后不能supervisord -c supervisord.conf
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
For help, use /root/.virtualenvs/bmxf/bin/supervisord -h
尝试unlink /tmp/supervisor.sock和unlink /var/run/supervisor.sock
这篇关于使用supervisor管理daphne进程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!