提交 fb9bd8c0 编写于 作者: H hjdhnx

优化了linux下更舒服的启动方法

上级 3253a1ae
...@@ -194,20 +194,21 @@ def config_render(mode): ...@@ -194,20 +194,21 @@ def config_render(mode):
@app.route('/configs') @app.route('/configs')
def config_gen(): def config_gen():
# 生成文件 # 生成文件
os.makedirs('txt',exist_ok=True)
set_local = render_template('config.txt',rules=getRules('js'),mode=0,host=getHost(0)) set_local = render_template('config.txt',rules=getRules('js'),mode=0,host=getHost(0))
set_area = render_template('config.txt',rules=getRules('js'),mode=1,host=getHost(1)) set_area = render_template('config.txt',rules=getRules('js'),mode=1,host=getHost(1))
set_online = render_template('config.txt',rules=getRules('js'),mode=1,host=getHost(2)) set_online = render_template('config.txt',rules=getRules('js'),mode=1,host=getHost(2))
with open('pycms0.json','w+',encoding='utf-8') as f: with open('txt/pycms0.json','w+',encoding='utf-8') as f:
set_dict = json.loads(set_local) set_dict = json.loads(set_local)
f.write(json.dumps(set_dict,ensure_ascii=False,indent=4)) f.write(json.dumps(set_dict,ensure_ascii=False,indent=4))
with open('pycms1.json','w+',encoding='utf-8') as f: with open('txt/pycms1.json','w+',encoding='utf-8') as f:
set_dict = json.loads(set_area) set_dict = json.loads(set_area)
f.write(json.dumps(set_dict,ensure_ascii=False,indent=4)) f.write(json.dumps(set_dict,ensure_ascii=False,indent=4))
with open('pycms2.json','w+',encoding='utf-8') as f: with open('txt/pycms2.json','w+',encoding='utf-8') as f:
set_dict = json.loads(set_online) set_dict = json.loads(set_online)
f.write(json.dumps(set_dict,ensure_ascii=False,indent=4)) f.write(json.dumps(set_dict,ensure_ascii=False,indent=4))
files = [os.path.abspath(f'pycms{i}.json') for i in range(3)] files = [os.path.abspath(rf'txt\pycms{i}.json') for i in range(3)]
# print(files) # print(files)
return jsonify(error.success('猫配置生成完毕,文件位置在:\n'+'\n'.join(files))) return jsonify(error.success('猫配置生成完毕,文件位置在:\n'+'\n'.join(files)))
......
[inet_http_server] ; inet (TCP) server disabled by default
port=*:9001 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
[supervisord]
;nodaemon=true
logfile=logs/supervisord.log
logfile_maxbytes=50MB
[supervisorctl]
[program:flask_dr_py]
command=python3 app.py ; 被监控的进程路径
directory=/root/sd/pywork/dr_py ; 执行前要不要先cd到目录去,一般不用
user=root ;执行者角色
priority=1 ;数字越高,优先级越高
;numprocs=1 ; 启动几个进程
startsecs=0
autostart=true ; 随着supervisord的启动而启动
autorestart=true ; 自动重启。。当然要选上了
startretries=10 ; 启动失败时的最多重试次数
exitcodes=0 ; 正常退出代码(是说退出代码是这个时就不再重启了吗?待确定)
stopsignal=KILL ; 用来杀死进程的信号
stopwaitsecs=10 ; 发送SIGKILL前的等待时间
redirect_stderr=true ; 重定向stderrstdout
;stopasgroup=true ;用于停止进程组,即停止所有通过“uwsgi.ini”配置启动的进程。
;killasgroup=true ;用于关闭进程组,即关闭所有通过“uwsgi.ini”配置启动的进程。
\ No newline at end of file
#### dr模板的python实现 #### dr模板的python实现
###### 更新日志 ###### 更新日志
###### 2022/08/28
- [X] 1.增加linux进程启动,命令 supervisord -c manager.conf
- [X] 2.转移文本文件到txt目录
###### 2022/08/27 ###### 2022/08/27
- [X] 1.增加PC_UA变量 - [X] 1.增加PC_UA变量
- [X] 2.首页增加更多功能按钮 - [X] 2.首页增加更多功能按钮
......
...@@ -3,5 +3,6 @@ pyquery ...@@ -3,5 +3,6 @@ pyquery
flask flask
requests requests
flask-sqlalchemy flask-sqlalchemy
gevent netifaces
netifaces gevent ; python_version < '3.9'
\ No newline at end of file supervisor ; sys_platform != 'win32' and python_version < '3.9'
\ No newline at end of file
service supervisord start #启动,默认配置文件
service supervisord stop #停止
service supervisord status #状态
supervisorctl shutdown #关闭所有任务
supervisorctl stop|start program_name #启动或停止服务
supervisorctl status #查看所有任务状态
kill -9 $(cat supervisord.pid) # 杀掉进程
supervisord -c manager.conf # 启动服务
echo_supervisord_conf > ./cmd.conf #输出配置
\ No newline at end of file
{ {
"dr_count": 6, "dr_count": 9,
"mode": 0, "mode": 0,
"sites": [ "sites": [
{ {
...@@ -29,6 +29,15 @@ ...@@ -29,6 +29,15 @@
"quickSearch": 1, "quickSearch": 1,
"filterable": 1 "filterable": 1
}, },
{
"key": "dr_夜空",
"name": "夜空(道长)",
"type": 1,
"api": "http://localhost:5705/vod?rule=夜空",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{ {
"key": "dr_玩偶姐姐", "key": "dr_玩偶姐姐",
"name": "玩偶姐姐(道长)", "name": "玩偶姐姐(道长)",
...@@ -38,6 +47,24 @@ ...@@ -38,6 +47,24 @@
"quickSearch": 1, "quickSearch": 1,
"filterable": 1 "filterable": 1
}, },
{
"key": "dr_瓜皮TV",
"name": "瓜皮TV(道长)",
"type": 1,
"api": "http://localhost:5705/vod?rule=瓜皮TV",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{
"key": "dr_莫扎兔",
"name": "莫扎兔(道长)",
"type": 1,
"api": "http://localhost:5705/vod?rule=莫扎兔",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{ {
"key": "dr_蓝莓影视", "key": "dr_蓝莓影视",
"name": "蓝莓影视(道长)", "name": "蓝莓影视(道长)",
......
{ {
"dr_count": 6, "dr_count": 9,
"mode": 1, "mode": 1,
"sites": [ "sites": [
{ {
...@@ -29,6 +29,15 @@ ...@@ -29,6 +29,15 @@
"quickSearch": 1, "quickSearch": 1,
"filterable": 1 "filterable": 1
}, },
{
"key": "dr_夜空",
"name": "夜空(道长)",
"type": 1,
"api": "http://192.168.3.224:5705/vod?rule=夜空",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{ {
"key": "dr_玩偶姐姐", "key": "dr_玩偶姐姐",
"name": "玩偶姐姐(道长)", "name": "玩偶姐姐(道长)",
...@@ -38,6 +47,24 @@ ...@@ -38,6 +47,24 @@
"quickSearch": 1, "quickSearch": 1,
"filterable": 1 "filterable": 1
}, },
{
"key": "dr_瓜皮TV",
"name": "瓜皮TV(道长)",
"type": 1,
"api": "http://192.168.3.224:5705/vod?rule=瓜皮TV",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{
"key": "dr_莫扎兔",
"name": "莫扎兔(道长)",
"type": 1,
"api": "http://192.168.3.224:5705/vod?rule=莫扎兔",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{ {
"key": "dr_蓝莓影视", "key": "dr_蓝莓影视",
"name": "蓝莓影视(道长)", "name": "蓝莓影视(道长)",
......
{ {
"dr_count": 6, "dr_count": 9,
"mode": 1, "mode": 1,
"sites": [ "sites": [
{ {
...@@ -29,6 +29,15 @@ ...@@ -29,6 +29,15 @@
"quickSearch": 1, "quickSearch": 1,
"filterable": 1 "filterable": 1
}, },
{
"key": "dr_夜空",
"name": "夜空(道长)",
"type": 1,
"api": "http://cms.nokia.press/vod?rule=夜空",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{ {
"key": "dr_玩偶姐姐", "key": "dr_玩偶姐姐",
"name": "玩偶姐姐(道长)", "name": "玩偶姐姐(道长)",
...@@ -38,6 +47,24 @@ ...@@ -38,6 +47,24 @@
"quickSearch": 1, "quickSearch": 1,
"filterable": 1 "filterable": 1
}, },
{
"key": "dr_瓜皮TV",
"name": "瓜皮TV(道长)",
"type": 1,
"api": "http://cms.nokia.press/vod?rule=瓜皮TV",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{
"key": "dr_莫扎兔",
"name": "莫扎兔(道长)",
"type": 1,
"api": "http://cms.nokia.press/vod?rule=莫扎兔",
"searchable": 1,
"quickSearch": 1,
"filterable": 1
},
{ {
"key": "dr_蓝莓影视", "key": "dr_蓝莓影视",
"name": "蓝莓影视(道长)", "name": "蓝莓影视(道长)",
......
kill -9 $(cat supervisord.pid)
supervisord -c manager.conf
\ No newline at end of file
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /root/sd/pywork/dr_py/manager.conf # 启动命令
ExecStop=/usr/bin/supervisorctl shutdown # 停止程序的命令
ExecReload=/usr/bin/supervisorctl reload # 重启进程的命令
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册