使用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

猜你喜欢

转载自blog.csdn.net/sinat_26809255/article/details/121156210