安装
1
|
pip install supervisord
|
安装完成,在项目根目录创建conf目录, 这个目录位置自己随意创建 生成conf文件
1
2
3
|
echo_supervisord_conf > conf配置文件名称
echo_supervisord_conf > test_supervisord.conf
|
生成之后配置Asgi,将一下配置添加进创建的conf文件
1
2
3
4
5
6
7
|
[program:daphne]
directory = / mnt / crdagvd / wechartcustservices / server / wechatSystem
command = daphne - b 0.0 . 0.0 - p 8081 - - proxy - headers wechatSystem.asgi:application
autostart = true
autorestart = true
stdout_logfile = / mnt / crdagvd / wechartcustservices / server / logs / websocket.log
redirect_stderr = true
|
添加配置完成之后,启动进程
nginx配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
upstream wsbackend {
server 127.0 . 0.1 : 8081 ;
}
location / ws {
proxy_pass http: / / wsbackend;
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;
}
|
配置到这里 asgi 就配置完成了,
下边是一个配置 执行python脚本的
1
2
3
4
5
6
|
[program:wechartBot]
command = python / mnt / crdagvd / wechartcustservices / wechart_middle / WechatMiddle / wechat / wechat_server.py
stderr_logfile = / mnt / crdagvd / wechartcustservices / wechart_middle / logs / wechart_server.log
stdout_logfile = / mnt / crdagvd / wechartcustservices / wechart_middle / logs / wechart_error.log
autostart = true
autorestart = true
|