diff --git a/app.py b/app.py index ea9f2239fefb45680feb5ac6678b5ed317ec9075..5f0d4dacea37c472fed05a21b1f1d14f85d65f97 100644 --- a/app.py +++ b/app.py @@ -194,20 +194,21 @@ def config_render(mode): @app.route('/configs') def config_gen(): # 生成文件 + os.makedirs('txt',exist_ok=True) 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_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) 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) 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) 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) return jsonify(error.success('猫配置生成完毕,文件位置在:\n'+'\n'.join(files))) diff --git a/manager.conf b/manager.conf new file mode 100644 index 0000000000000000000000000000000000000000..c2b34914d55b28d05f24891d63be5d3dfd7580e4 --- /dev/null +++ b/manager.conf @@ -0,0 +1,26 @@ + [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 ; 重定向stderr到stdout +;stopasgroup=true ;用于停止进程组,即停止所有通过“uwsgi.ini”配置启动的进程。 +;killasgroup=true ;用于关闭进程组,即关闭所有通过“uwsgi.ini”配置启动的进程。 \ No newline at end of file diff --git a/readme.md b/readme.md index 186450a0b6cf6fbd0fbff7f7d610fbb2d45f7171..0a0ed292005afc7501968913105bb94dd9ee4831 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,8 @@ #### dr模板的python实现 ###### 更新日志 +###### 2022/08/28 +- [X] 1.增加linux进程启动,命令 supervisord -c manager.conf +- [X] 2.转移文本文件到txt目录 ###### 2022/08/27 - [X] 1.增加PC_UA变量 - [X] 2.首页增加更多功能按钮 diff --git a/requirements.txt b/requirements.txt index 7b389bf2df83f2c6ea1ffad49385ce26f799ee36..ee0a9578242ae4db60bc42fa894e0a7ccbf744ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,6 @@ pyquery flask requests flask-sqlalchemy -gevent -netifaces \ No newline at end of file +netifaces +gevent ; python_version < '3.9' +supervisor ; sys_platform != 'win32' and python_version < '3.9' \ No newline at end of file diff --git a/txt/help.txt b/txt/help.txt new file mode 100644 index 0000000000000000000000000000000000000000..5625c1e1465d18768363c4a9f0e134243beef22f --- /dev/null +++ b/txt/help.txt @@ -0,0 +1,9 @@ +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 diff --git a/libs.txt b/txt/libs.txt similarity index 100% rename from libs.txt rename to txt/libs.txt diff --git a/pycms0.json b/txt/pycms0.json similarity index 92% rename from pycms0.json rename to txt/pycms0.json index 7cee603ae605f3f49201df1474368f36cf259623..a583bb488475c39dc0d630ecf92c16e7e3292ade 100644 --- a/pycms0.json +++ b/txt/pycms0.json @@ -1,5 +1,5 @@ { - "dr_count": 6, + "dr_count": 9, "mode": 0, "sites": [ { @@ -29,6 +29,15 @@ "quickSearch": 1, "filterable": 1 }, + { + "key": "dr_夜空", + "name": "夜空(道长)", + "type": 1, + "api": "http://localhost:5705/vod?rule=夜空", + "searchable": 1, + "quickSearch": 1, + "filterable": 1 + }, { "key": "dr_玩偶姐姐", "name": "玩偶姐姐(道长)", @@ -38,6 +47,24 @@ "quickSearch": 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_蓝莓影视", "name": "蓝莓影视(道长)", diff --git a/pycms1.json b/txt/pycms1.json similarity index 92% rename from pycms1.json rename to txt/pycms1.json index 7f470de48315e4d45f1a9f597be308edba2fa2bd..21a4020d6aea2da9e0036f72feb7744b6a8cca25 100644 --- a/pycms1.json +++ b/txt/pycms1.json @@ -1,5 +1,5 @@ { - "dr_count": 6, + "dr_count": 9, "mode": 1, "sites": [ { @@ -29,6 +29,15 @@ "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_玩偶姐姐", "name": "玩偶姐姐(道长)", @@ -38,6 +47,24 @@ "quickSearch": 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_蓝莓影视", "name": "蓝莓影视(道长)", diff --git a/pycms2.json b/txt/pycms2.json similarity index 92% rename from pycms2.json rename to txt/pycms2.json index 94def55fda66876ae2053118209cba76a283d892..3e1975e1bb11549548b683211345edb2b586d9d4 100644 --- a/pycms2.json +++ b/txt/pycms2.json @@ -1,5 +1,5 @@ { - "dr_count": 6, + "dr_count": 9, "mode": 1, "sites": [ { @@ -29,6 +29,15 @@ "quickSearch": 1, "filterable": 1 }, + { + "key": "dr_夜空", + "name": "夜空(道长)", + "type": 1, + "api": "http://cms.nokia.press/vod?rule=夜空", + "searchable": 1, + "quickSearch": 1, + "filterable": 1 + }, { "key": "dr_玩偶姐姐", "name": "玩偶姐姐(道长)", @@ -38,6 +47,24 @@ "quickSearch": 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_蓝莓影视", "name": "蓝莓影视(道长)", diff --git a/txt/run.sh b/txt/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..b99d5d29bd04aebf89f0e4b36642121989ce6ddd --- /dev/null +++ b/txt/run.sh @@ -0,0 +1,2 @@ +kill -9 $(cat supervisord.pid) +supervisord -c manager.conf \ No newline at end of file diff --git a/txt/supervisord.service b/txt/supervisord.service new file mode 100644 index 0000000000000000000000000000000000000000..bb989c92cc57cac77d338f526bfa00f0764eea8e --- /dev/null +++ b/txt/supervisord.service @@ -0,0 +1,14 @@ +[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